Answer the question
In order to leave comments, you need to log in
How to form the correct route for requests with a hyphen?
Good afternoon!
How to implement correct route
Input lines are like this:
/blog/zero-six-five
/post/one-two-three
/post/one-two-three-moscow-zao
Для /post/one-two-three-moscow-zao на выходе должно получиться $ver0=post, $ver1=one-two-three, $ver2=moscow, $ver3=zao
Для /post/one-two-three $ver0=post, $ver1=one-two-three
Для /blog/zero-six-five $ver0=blog, $ver1=zero-six-five
Route::get('/{category}/{variable_one}-{variable_two}-{variable_three}', ['uses' => 'Site\[email protected]_test'])
->where('variable_one', '.*')
->where('variable_two', '.*')
->where('variable_three', '.*');
Answer the question
In order to leave comments, you need to log in
"one-two-three-moscow-zao" Do you have PHP to vang something, what do you want to pull out??? With a pattern like yours in the route, the vars themselves should not have a dash, but they do. So your pattern will work at most for exactly three-syllable words. Secondly, why the hell would you separate these variables directly in the route?
I will write a solution, but if you solve such basic tasks in this way, then this is not for you.
ALL. Further, if you really need it, you can create a binder pattern in the service provider, or divide the title into parts directly in the controller.
With such approach as at you now to implement it it is NOT POSSIBLE.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question