Laravel 4 - Blade Templating - How to properly Link to Route?
Use URL::route()
to get just a link:
<a href="{{ URL::route('user/profile/', $params) }}">
<i class="icon-dashboard"></i>
<span class="menu-text"> Dashboard </span>
</a>
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>
If you Route use a Closure, you can use URL::to()
, like this
<a href="{{ URL::to('home/otherpage', $params) }}">
<i class="icon-dashboard"></i>
<span class="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:
<a href="{{ URL::route('routeName', $params) }}">
<i class="icon-dashboard"></i>
<span class="menu-text"> Dashboard </span>
</a>
(ref: https://laravel.com/docs/5.0/helpers#urls)