Reputation: 6276
I've gone through many of the articles below, which explains generating link from named route, but unable to solve my problem.
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:
Upvotes: 8
Views: 46325
Reputation: 169
Below code will work.
<a href="{{ route('/cardetails', ['121','cars'] ) }}">click </a>
In URL it will be like this below line.
127.0.0.1:8000/cardetails/121/cars
Upvotes: 1
Reputation: 1407
In your route put name and
Route::get('/nitsadmin/dashboard', function () {
return view('nitsadmin.dashboard')->name(nitsadmin.dashboard);
});
Go to your html where you link the url
<a id="index" class="navbar-brand" href="{{route('nitsadmin.dashboard')}}">
<img src="../img/admin/nitseditorlogo.png" alt="Logo">
</a>
Upvotes: 1
Reputation: 2325
For coders using routes names, simply they can use to() method:
return redirect()->to(route('dashboard').'#something');
In templates:
{{ route('dashboard').'#something' }}
Upvotes: 16
Reputation: 4022
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>
Upvotes: 1
Reputation: 16339
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.
Upvotes: 13