In Laravel, if I perform a query:
$foods = Food::where(...)->get();
...then $foods is an Illuminate Collection of Foo
I have to point out that there is a small but absolutely CRITICAL error in kalley's answer. I struggled with this for several hours before realizing:
Inside the function, what you are returning is a comparison, and thus something like this would be more correct:
$desired_object = $food->filter(function($item) {
return ($item->id **==** 24);
})->first();