I am trying to create this structure on PHP
and I don't know how to I create an array of object on PHP. It always get the last data from the object.
This is my current code:
array(
"description": getDescription($id),
"deposit": getPrices($id);
)
function getPrices($id) {
$test = Prices::where('price_id',$id)->where('promo',0)->get();
$price = [];
$data = [];
foreach($test as $t) {
$data["item_id"] = $t->id;
$data["price"] = $t->list;
$data["type"] = $t->type;
$price = $data;
}
return $price;
}