Guys I'm trying to get the result form my database by laravel 5.5. If I run this code:
DB::table('comments')->get()
It will return an array which contains stdClasses. Now I want the key(index) of each stdClass in the array be ID of the stdClass.
I just want to know that laravel has this feature ?
Update: This is returned Array for example:
Illuminate\Support\Collection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[id] => 7
....
)
[1] => stdClass Object
(
[id] => 8
....
)
[2] => stdClass Object
(
[id] => 9
....
)
)
)
notice above code. I want 7,8,9 to be instead of 0,1,2 .