+1 vote
by
What to do in such cases?

Route::get('/{page}', 'Frontend\PageController@index');
Route::get('/{catalog}', 'Frontend\CatalogController@index');
Route::get('/{catalog}/{filters?}', 'Frontend\CatalogController@filters');
Route::get('/{catalog}{product}', 'Frontend\ProductController@index');

The first solution that comes to mind is to create a route for page and catalog and then search the database by url and produce different results.

What if there are 10,000 pages? What if there are 3 different types of pages and you need to keep the url at 1 level? And so on.

2 Answers

0 votes
by
 
Best answer
Use prefixes:
Route::get('/page-{page}', 'Frontend\PageController@index');
Route::get('/catalog-{catalog}', 'Frontend\CatalogController@index');
Route::get('/catalog-{catalog}/{filters?}', 'Frontend\CatalogController@filters');
Route::get('/catalog-{catalog}/product-{product}', 'Frontend\ProductController@index');
+1 vote
by
Since only.... above everywhere they say to use multiple resource naming but I don't like it...

Route::get('/page/{page}', 'Frontend\PageController@index');
Route::get('/catalog/{catalog}', 'Frontend\CatalogController@index');
Route::get('/catalog/{catalog}/{filters?}', 'Frontend\CatalogController@filters');
Route::get('/catalog/{catalog}/product/{product}', 'Frontend\ProductController@index');
Naming complex actions in REST API
...