How to put route in anchor tag in laravel 5.2

Nitish Kumar picture Nitish Kumar · Jun 8, 2016 · Viewed 24.9k times · Source

I've gone through many of the articles below, which explains generating link from named route, but unable to solve my problem.

Tutorial 1

Tutorial 2

Tutorial 3

Following is the defined routes:

Route::get('/nitsadmin/dashboard', function () {
    return view('nitsadmin.dashboard');
});

And I'm calling link in anchor tag:

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

I'm getting following error:

enter image description here

Answer

ClearBoth picture ClearBoth · Jan 12, 2017

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

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

In templates:

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