0

I want dynamic uri for Auth routes depending on the language.
Is there a way to get a route result by name?

For example with the Auth routes:

Route::get(route('login')); 

Thank you for your ideas...

2
  • 1
    why are creating a route of a route ? Commented Feb 22, 2017 at 16:36
  • I want dynamic uri for Auth routes... depends on language. Commented Feb 22, 2017 at 16:42

2 Answers 2

1

I normally use them as such:

//Routes Route::post('/login',[ 'uses'=>'HomeController@login', 'as'=>'login' ]); // Calling them in blade {{route('login')}} -> xxxxx/login 

You can still get more information on the best documentation of the world: https://laravel.com/docs/5.4/routing#named-routes

Sign up to request clarification or add additional context in comments.

Comments

0

If you want the url for the named route, for example to use it in your views, you should just use route('routename') (ofcourse you should replace route_name with the name of your route). You do not need the Route::get around that, the Route::get/post/put/patch/delete functions are for defining new routes, not to get the url for a route.

Take a look at https://laravel.com/docs/5.4/routing#named-routes on how to create named routes and properly link to them.

Comments