Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel reverse routing benefits

Tags:

laravel

routes

As per this link, we have been told that with reverse routing, we can generate links. But Laravel already provides named routing for the same. As well as there is another way to generate link is the route helper function.

Then what is actual benefit of using reverse routing in Laravel?

like image 671
Ravi Maniyar Avatar asked Aug 08 '18 17:08

Ravi Maniyar


2 Answers

Laravel reverse routing benefit should be apparent. Say you want to change your login URL to users/signin, if you aren't using named routes you'd have to go through and manually change all URLs to point to the new URL. That's a lot of wasted time. With named routes you simply change the route in routes.php and all of your links will now point to the new UR.

You can check this link for detail description about reverse routing. http://jasonlewis.me/article/laravel-reverse-routing

like image 189
Jeel Prajapati Avatar answered Sep 30 '22 18:09

Jeel Prajapati


Why nobody is referring this --> {{route('user.login')}} while you declared this name to route. Can we say this is a reverse routing?

Just you have to declare the following:

Route::get('login', 'users@login')->name('user.login');
like image 33
Meral Avatar answered Sep 30 '22 19:09

Meral