Laravel 4 - Blade Templating - How To Properly Link To Route?
I want to create a resourceful link with Laravel. Normally I just use the {{ link_to_route('Yadayadayada.route', 'LinkName', $params }} But in this case I am using a Template with
Solution 1:
Use URL::route()
to get just a link:
<ahref="{{ URL::route('user/profile/', $params) }}"><iclass="icon-dashboard"></i><spanclass="menu-text"> Dashboard </span></a>
Solution 2:
If you Route use a Closure, you can use URL::to()
, like this
<ahref="{{ URL::to('home/otherpage', $params) }}"><iclass="icon-dashboard"></i><spanclass="menu-text"> Dashboard </span></a>
As @orrd sugested, in general terms is better to use named routes, so it can be easily change the URL later:
<ahref="{{ URL::route('routeName', $params) }}"><iclass="icon-dashboard"></i><spanclass="menu-text"> Dashboard </span></a>
Solution 3:
if you define Route name you can use that in your blade :
Route::get('/admin/transfer/forms-list', [
'as' => 'transfer.formsList',
'uses' => 'Website\TransferController@IndexTransferForms'
]);
now you can use that in your blade like this :
<a href="{{URL::route('transfer.formsList')}}"type="submit">
discard</a>
Solution 4:
There are no of ways to use route in blade:
1. Use Action
{{URL::action('DemoController@index',$params)}}
2. Use Route
{{ URL::route('route/', $params) }}
3. Use URL to
{{ URL::to('route/name', $params)) }}
Solution 5:
Use URL::route() to get just a link:
<ahref="{{ URL::route('user/profile/', $params) }}"><iclass="icon-dashboard"></i><spanclass="menu-text"> Dashboard </span></a>
Post a Comment for "Laravel 4 - Blade Templating - How To Properly Link To Route?"