V
V
Valeria_Rayshite2017-08-04 08:52:50
Laravel
Valeria_Rayshite, 2017-08-04 08:52:50

How to use different controllers depending on the route parameter?

There is a route

Route::get('/{lang}/{unit}/{slug}', [
  'as' => 'article', 'uses' => '[email protected]'
]);

How to make the route
Route::get('/{lang}/{unit}/contact', [
   //
]);

handled by another controller?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2017-08-04
@Valeria_Rayshite

You need to specify routes in order from hard to flexible, and not vice versa

Route::get('/{lang}/{unit}/contact', [
   'as' => 'contact', 'uses' => '[email protected]'
]);
Route::get('/{lang}/{unit}/{slug}', [
  'as' => 'article', 'uses' => '[email protected]'
]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question