I have web pages that have search form
that need to populate data from database like category
, there lot of page on my site like gallery
blog
etc
.
every page has the same search form
.
so I decide to use @section
and @extend
for main content and keep the search form
on my main layout
.
here my controller
public function index()
{
$post = Post::all();
$categories = Category::all();
return view('events.show', compact('post', 'category'));
}
public function show($slug)
{
$post = Post::where('slug',$slug)->first();
$categories = Category::all();
return view('events.show', compact('post', 'category'));
}
on my code above I need to call category
list like every function
also every controller
there's a way to make it without $categories = Category::all();
every function
also every controller
?...
so just call once and work every page.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire