Answer the question
In order to leave comments, you need to log in
How to properly write nested routes?
Hello. You need to make routes:
sitename.ru/articles //получаем все артиклы
sitename.ru/articles/slugArticle //переход на артикл из ./articles
sitename.ru/articles/slugCategory //выводим артиклы данной категории
sitename.ru/articles/slugCategory/slugArticle //переход по артиклу данной категории
Route::get('/recipes','[email protected]');
Route::get('/recipes/{slugRecipe}','[email protected]');
Route::get('/recipes/{slugTag}', '[email protected]');
Route::get('/recipes/{slugTag}/{slugRecipe}', '[email protected]');
Answer the question
In order to leave comments, you need to log in
You cannot create the same routes for different controllers.
I can advise you to create a single controller, for example RouteController , in which to search for Article by the passed slug. If it is found, call the required method from the ArticlesController, if not, call it from the CategoriesController.
Naturally, Lara scolds me for such crooked routes...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question