Answer the question
In order to leave comments, you need to log in
How to make a dynamic prefix for a router?
There is a project in which it is necessary to
display the name of the
city
as
a
prefix
for
some
pages
,
that
is
: , all addresses must go to their controllers, regardless of the prefix. What is the best way to implement this?
How to use a dynamic prefix (including the option without a prefix should work)?
I tried many different options, everything works somehow crookedly.
Answer the question
In order to leave comments, you need to log in
Let's say the visitor has chosen a region, and we have put the code of this region in his session.
Then you can do this:
Route::prefix(session('region_code'))->group(function() {
Route::get('catalog', '...');
// ...
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question