Post date: Mar 29, 2015 4:45:47 PM
Creating Route Aliases
Route aliases (also referred to as named routes) are useful because you can use the route name when creating links within your views, allowing you to later change the route path in the annotation without worrying about breaking the associated links. For instance the following definition associates a route with an alias named blog.category
:
1
Route::get('blog/category/{category}',
2
['as'
=>
'blog.category',
'uses'
=>
'BlogController@category']);
Once defined, you can reference routes by their alias using the URL::route
method:
1
<a
href="{{ URL::route('blog.category', ['category' => 'mysql']) }}">MySQL</a>
php artisan route:list