What is reverse routing in Laravel?

2024-04-18 07:04:43 Shruti Laravel

Reverse Routing in Laravel

In Laravel reverse routing is generating URL's based on route declarations.Reverse routing makes your application so much more flexible.

For example, the below route declaration tells Laravel to execute the action "login" in the user's controller when the request’s URI is 'login'.

//http://mysite.com/login

Route::get('login', 'users@login');

Using reverse routing we can create a link to it and pass in any parameters that we have defined. Optional parameters, if not supplied, are removed from the generated link.

{{ HTML::link_to_action('users@login') }}

It will create a link like http://mysite.com/login in view

This post is submitted by one of our members. You may submit a new post here.

Related Tricks