Route::get('/blog', 'BlogController@index')->name('blog');
Route::get('/blog/tag/{tag}', 'BlogController@index')->name('blog');
Route::get('/blog/category/{category}', 'BlogController@index')->name('blog');
I want to redirect different urls to same controller.
If the user filter for tag, send me link like : blog/tag/sample-tag
Or category : blog/category/sample-category
Or if user wants to see all blog : blog
I want to check in BlogController's index method like :
if ($request->has('tag') // return tag's blog content
else if ($request->has('category') // return category's blog content
else // return all blog content.
Laravel 5.6.*
Error:
Missing required parameters for [Route: blog] [URI: blog/category/{category}]
I call like this : <li><a href="{{ route('blog') }}">BLOG</a></li>
/blog?tag=laravel&category=programming