what is Named Routes

Answer

Named routes allow you to conveniently generate URLs or redirects for a specific route. You may specify a name for a route with the as array key:

Route::get('user/profile', ['as' => 'profile', function()
{
    //
}]);

You may also specify route names for controller actions:

Route::get('user/profile', [
    'as' => 'profile', 'uses' => 'UserController@showProfile'
]);

Now, you may use the route's name when generating URLs or redirects:

$url = route('profile');

$redirect = redirect()->route('profile');

The currentRouteName method returns the name of the route handling the current request:

$name = Route::currentRouteName();

All laravel Questions

Ask your interview questions on laravel

Write Your comment or Questions if you want the answers on laravel from laravel Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---