I'm Trying to display restaurant Menus grouped by the categories, for example...
- Lunch
- Chicken and Chips
- Rice
- Breakfast
- Tea
- Coffee So I have 3 tables in my database, Restaurants, Categories, And Menus
Restaurants controller
public function show($slug, RestaurantRepository $repository){
if(! $restaurant = $repository->get(['slug' => $slug], with(['cuisines','user', 'photos', 'thumbs', 'region', 'ratings.user']))) return abort('404');
$menus=Menu::with(['category_type'])->where('restaurant_id',$restaurant->id)->get()->groupBy('category_id');
return view('frontend.restaurant.show', compact('restaurant', 'p','menus'));
}
when i Dump this it looks just fine.
Results have been grouped
Now my trouble is on the View when i try to get results of this i get an error.
@if($menus)
<ul>
@foreach($menus as $m)
<li>
</li>
@endforeach
</ul>
@endif
ErrorException (E_ERROR).
Property [name] does not exist on this collection instance.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire