Consider the main category subcategory mentality. I want to have the following when a link is clicked.
I can do : www.localhost.com/category/
i want to do: www.localhost.com/category/vehicle
derivatives: www.localhost.com/category/vehicle/bmw www.localhost.com/category/vehicle/bmw/bmm-x7-series
Route::get('/category/{id}', 'CategoryController@index')->name('category.index'); ` my route below:
Route::get('/category/{slug}', 'CategoryController@index')->where('slug' , '[\w\d\-\_]+'); I created a control named CategoryController
class CategoryController extends Controller { public function index($slug) { $category = Category::where('slug' , $slug)->first(); return view('category.show' , compact('category')); } my view content(category.show.blade.php)
{{$category->slug}} <a href="{{ url('/category/' . $category->slug) }}" class="uhover">life is good. {{url($category->slug)}}</a>
{id}token, which IIRC laravel thinks should be an integer, so maybe try using a different variable name. Also, this question may provide some context for your conundrum.