Home > Back-end >  how can I print user_Id from this array format?
how can I print user_Id from this array format?

Time:10-21

Illuminate\Support\Collection Object
    (
        [items:protected] => Array
            (
                [0] => stdClass Object
                    (
                        [user_id] => 3
                    )    
            )    
    )

I am using Laravel 8. I want to fetch single data and use it.

CodePudding user response:

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.

  • Related