I want to make drop-down list filtering.
I have a web page, that shown some post with title and categories.
The page has a drop-down in nav.blade.php
This would get you started:
Assuming you have a route like:
Route::get('/{category_id}', ['as'=>'home', 'uses'=>'PostController@show']);
In the PostController@show
method:
public function show($category_id)
{
$categories = Category::all();
$selected_category = Category::with('posts')->where('id', $category_id)->first();
$posts = $selected_category->posts;
return redirect()->back()->with(compact('posts', 'categories'));
}
You can change the redirect location.