How to put route in anchor tag in laravel 5.2

久未见 提交于 2019-11-29 07:55:34

You can do this quite simply with the url() helper.

Just replace your anchor tag like so:

<a id="index" class="navbar-brand" href="{{url('/nitsadmin/dashboard')}}">
      <img src="../img/admin/nitseditorlogo.png" alt="Logo">
</a>

Regarding the image that you have used in there, if these were to be stored in your public folder then you could always use the asset() helper. This would help you turn your absolute links to in dynamic ones.

For coders using routes names, simply they can use to() method:

return redirect()->to(route('dashboard').'#something');

In templates:

{{ route('dashboard').'#something' }}

Lets say you have route like these....

Route::get('/nitsadmin/dashboard', function () {
    return view('nitsadmin.dashboard');
});
Route::get('/land', 'HomeController@landingPage');
Route::get('/role-permission/add',          ['as' => 'mp.rp.add',          'uses' => 'RolePermissionMapController@add']);

so you can link like this --

<a href="{{url('/nitsadmin/dashboard')}}">Click </a>
<a href="{{url('/land')}}">Click </a>
<a href="{{url('/role-permission/add')}}">Click </a>
<a href="{{route('mp.rp.add')}}">Click </a>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!