IlluminateSupportCollection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[user_id] => 3
)
)
)
I am using Laravel 8. I want to fetch single data and use it.
Advertisement
Answer
Please don’t use print_r to dump your records. kindly use dd() or dump(). So you have a clear idea about collections. So as of now, you fetch as
$yourCollection->first()->user_id
if you have multiple models you can use loops.