Naming routes in Laravel

In some cases, it can be extremely useful to give an id or name to our routes, and Laravel makes it the easiest thing in the world.

Here is how to name a route in your routes.php file.

Route::get('/home', '[email protected]')->name('home');


Route::get('/home', ['as' => 'home', 'uses' => '[email protected]']);

This is how you can reference your named route, and you get the full URL with the route:

$url = route('home');



Have something on your mind?