I have defined a Category model and table that I'm filling through the backend of my Laravel application. I want to display the categories as menu items.
In my controller, I have something like
public function index()
{
$categories = Category::all();
return view('layouts.app', ['categories' => $categories]);
}
So the idea is that I can loop in the layouts.app template over these categories.
@foreach($categories as $category)
<li><a href="..." class="user-icon"> </a></li>
@endforeach
How can I make sure that my app displays these catagories on all pages (that use the layouts.app template). Normally one could create a route entry but how to do this for the layouts.app template?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire