Reputation: 79
i just want to make a button redirecting me to something like this"/loans/loans->id/edit"
where loans->id is from database, how should he href look?
<button href="{{ URL('/loans/{{$loan->id}}/edit')}}"
This is what i have until now and is giving error
Upvotes: 0
Views: 1503
Reputation: 4915
You are writing blade braces inside of another which will throw a Parse error. Because it will translate into this piece of code.
<button href="<?php echo e(URL('/loans/{{$loan->id); ?>/edit')}}"
Also if you want to write an expression inside of a string then use double quotes ""
and {}
single curly brace.
Try this.
<button href="{{ URL("/loans/{$loan->id}/edit") }}"
Also in your routes file add this route.
Route::get('/loans/{id}/edit', 'controller@method');
Upvotes: 1
Reputation: 2192
Your href should be like
href='loans/{{$load->id}}/edit'
And you should have the following inside your \routs\web.php
Route::get('/loans/{loan}/edit', 'LoansController@edit');
Upvotes: 0
Reputation: 838
first href you need to write in the tag a! You can use the helper route
<a htef="{{route('loans.edit',[$loans->id])}}">link</a>
and in the file of the router, write
Route::get('loans/{$id}/edit', 'yourcontroller@method')->name('loans.edit')
Upvotes: 0