T
T
TrustyWork2016-05-14 01:22:09
Laravel
TrustyWork, 2016-05-14 01:22:09

How to modify url with middleware in laravel 5?

Let's say the url /ru/path/to
is sent, the middleware detects /ru, does what it needs, and it's just /path/to that comes to the routes

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2016-05-14
Hrebet @hrebet

You can use grouping together with an intermediary:

Route::group(['prefix' => App::getLocale(), 'middleware' => 'LanguageMiddleware'], function() {
  Route::get('user', ['as' => 'user', 'uses' => '[email protected]']);
});

In order to avoid binding to a specific value of the current localization in the URL - you can allow all possible ones.
Good solution on GithHub Gist . ;-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question