S
S
seredaes2016-06-12 01:54:25
HTML
seredaes, 2016-06-12 01:54:25

How to correctly build a route in Laravel?

Route::any('/{lang?}', ['uses' => '[email protected]', 'as' => 'home']);
Route::any('/test', ['uses' => '[email protected]']);
So it will always reset to the index method, but how to make it reset to the test method in the HomeController controller?
I found a way, but it seems to me that it is a crutch. Please advise how to do it right!
thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vyacheslav Plisko, 2016-06-12
@AmdY

Specify a pattern with language options
$router->pattern('lang', 'ru|en');

A
Archakov Dennis, 2016-06-12
@archakov06

1. specify the path. for example /set/{lang?} & /set/test
2. Specify the request type ::post, ::get, ::any
3. I doubt it, but it's better to put the second line above the unknown value (route).

S
Sergey Semenko, 2016-06-12
@abler98

https://laracasts.com/discuss/channels/tips/exampl...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question