You have there a collection of objects
foreach ($data as $item) {
$item->Name;
// and so on
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This is my function. I need to display it in a productstock.blade.php in a table.
public function notavailable()
{
$data = DB::table('products')->where('Qty', '=', 0)->get();
dd($data);
}
This is the output of the function.
Illuminate\Support\Collection {#262 ▼
#items: array:1 [▼
0 => {#264 ▼
+"ProductID": 2
+"Name": "chair"
+"Brand": "dell"
+"image": "1616448515.jpg"
+"Description": "vhvjvkj"
+"Warranty": "three-year-Warranty"
+"Price": 7999
+"Qty": 0
+"Status": "Active"
+"AdminID": 1
+"created_at": "2021-03-22 21:28:35"
+"updated_at": "2021-03-22 21:34:04"
}
]
}
so. how can I solve this ??
You have there a collection of objects
foreach ($data as $item) {
$item->Name;
// and so on
}
Please or to participate in this conversation.