I have a book list which are in categories and subcategories.
Every category hasMany Subcategories. And every subcategory belongsTo a category in my Models.
Now I want to have routes like this:
books/{category?}
and
books/{category?}/{subcategory?}
my Routes look like this:
Route::resource('categories', 'ReligionsController');
Route::resource('category/{category?}', 'ReligionBranchController');
Route::get('category/{category?}/{subcategory?}', function()
{
return 'Quitter never win';
});
Now the Problem is, that my 2nd route works perfectly find, with my ReligionBranchController, but my last route (3rd) isn't working at all and I get this message:
Route pattern "/categories/{category}/{{category}}" cannot reference variable name "category" more than once.
How am I going to use dynamic routes like this:
example.org/category/fear/thriller
example.org/category/love/drama
example.org/category/love/science-fiction
Hope someone understands my trouble.
Route pattern "/categories/
and not the third, which starts withcategory
and notcategories
. – Antonio Carlos Ribeiro