use like below
 }})
use like this in img src="{{ asset('storage/admin/'.delete.png) }}"
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi! I want put image instead regular Bootstrap button.
{{ Form::button('<img src="../..(../../public/storage/admin/delete.png"/>', ['class' => 'img-delete mx-auto d-block form-control', 'type' => 'submit']) }}
I tried also with
<img src="{{ asset('storage/admin/delete.png') }}"/>
but it doesn't work! What I did wrong?
use like below
 }})
use like this in img src="{{ asset('storage/admin/'.delete.png) }}"
I think we can't use html tag over here. when i try to put full code with img src it shows a image now just check above code for a replace.
Can you write me that in my first code above? how to do it... because I am trying put your code and I don't succeed.
can you show your image saved path?
public/storage/admin/delete.png
img src="{{ asset('storage/admin/'.delete.png) }}"
{{ Form::button('img src="{{ asset('storage/admin/'.delete.png) }}"', ['class' => 'img-delete mx-auto d-block form-control', 'type' => 'submit']) }}
Like this?
@BarbaraTackaBa yes use <> in relavant places.
{{ Form::button('
', ['class' => 'img-delete mx-auto d-block form-control', 'type' => 'submit']) }}
I can't see your code.
Can someone help me with this? It doesn't work.
<td>
<a href="#deleteDirectory/{{ $item->id }}">
<img
{!! Form::open (['method' => 'POST', 'action' => ['DirectoriesController@destroy', $item->id]]) !!}
{!! Form::hidden('_method','DELETE')!!}
{{ Form::button'src' =>{{ asset('storage/admin/delete.png') }}' , ['class' => 'btn img-delete mx-auto d-block form-control', 'type' => 'submit' ]) }}
{!! Form::close() !!}
/>
</a>
</td>
I tried this but unfortunately it doesn't work.
@Cronix and @Snapey can you please check this? Thank you!
Someone told me to put image. I tried this. It doesn't work.
<td>
<a href="#deleteDirectory/{{ $item->id }}">
<img
{!! Form::open (['method' => 'POST', 'action' => ['DirectoriesController@destroy',$item->id]]) !!}
{!! Form::hidden('_method','DELETE')!!}
{!! Form::image('src' => '{{ asset("storage/admin/delete.png") }}',' ', ['class' => 'btn img-delete mx-auto d-block form-control', 'type' => 'submit' ] !!}
{!! Form::close() !!}
/>
</a>
</td>
You haven't changed your code yet. asset("storage/admin/delete.png") to asset("storage/admin/".delete.png)
@munazzil Yes, I also tried what you wrote but it doesn't work. :(
Error is: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
If your using asset don't need to use that storage.use like below and try.
< img src ="{{asset('admin/delete.png')}}"/>.
@munazzil I tried so many combinations. No, it still doesn't work. Error is:
syntax error, unexpected 'src' (T_STRING), expecting ',' or ')'
<td>
<a href="#deleteDirectory/{{ $item->id }}">
<
{!! Form::open (['method' => 'POST', 'action' => ['DirectoriesController@destroy',$item->id]]) !!}
{!! Form::hidden('_method','DELETE')!!}
{!! Form::button(img src = "{{ asset('admin/delete.png') }}", ['class' => 'img-delete mx-auto d-block form-control', 'type' => 'submit']) !!}
{!! Form::close() !!}
/>
</a>
</td>
without a form it will display.Did you check that.
<td>
<a href="#deleteDirectory/{{ $item->id }}">
{!! Form::open (['method' => 'POST', 'action' => ['DirectoriesController@destroy',$item->id]]) !!}
{!! Form::hidden('_method','DELETE')!!}
<img src="{{ asset('storage/admin/delete.png') }}" height=23 width=23 class="mx-auto d-block"/>
{!! Form::close() !!}
</a>
</td>
It shows button properly (that was ok before I put it in Form::) but it doesn't work. When I click on it, it doesn't delete anything.
And it doesn't work without storage in this case.
@BarbaraTackaBa if you don't mind can you show your controller function?
Did you mean this?
public function destroy($id)
{
$directories = Directory::find($id);
$directories->delete();
return redirect('/admin/directory')->with('success', 'Uspješno si izbrisao učesnika!');
}
Yes you have to use $directories instead of $item.
for better coding practice use as below.
$directories = Directory::findOrFail($id);
<td>
<a href="#deleteDirectory/{{ $directories->id }}">
{!! Form::open (['method' => 'POST', 'action' =>
['DirectoriesController@destroy', $directories>id]]) !!}
{!! Form::hidden('_method','DELETE')!!}
<img src="{{ asset('storage/admin/delete.png') }}" height=23
width=23 class="mx-auto d-block"/>
{!! Form::close() !!}
</a>
</td>
Here is my full code or view:
<tbody class="text-center">
@foreach($directories as $key => $item)
<tr>
<td scope="row">{{ $key+1 }}</td>
<td>{{ $item->name }}</td>
<td>{{ $item->surname }}</td>
<td>{{ $item->email }}</td>
<td>{{ $item->phone }}</td>
<td>{{ $item->town }}</td>
<td>{{ $item->country }}</td>
<td>{{ $item->gender }}</td>
<td>{{ $item->status }}</td>
<td><a href="#editDirectory/{{ $item->id }}"
data-item-id="{{ $item->id }}"
data-name="{{ $item->name }}"
data-surname="{{ $item->surname }}"
data-email="{{ $item->email }}"
data-phone="{{ $item->phone }}"
data-town="{{ $item->town }}"
data-country="{{ $item->country }}"
data-gender="{{ $item->gender }}"
data-status="{{ $item->status }}"
data-target="#editDirectory" data-toggle="modal">
<img src="{{ asset('storage/admin/edit.png') }}" height=23 width=23 class="mx-auto d-block"/>
</a>
</td>
<td>
<a href="#deleteDirectory/{{ $item->id }}">
{!! Form::open (['method' => 'POST', 'action' => ['DirectoriesController@destroy',$item->id]]) !!}
{!! Form::hidden('_method','DELETE')!!}
<img src="{{ asset('storage/admin/delete.png') }}" height=23 width=23 class="mx-auto d-block"/>
{!! Form::close() !!}
</a>
</td>
</tr>
@endforeach
</tbody>
can you show your route as well.
Route::resource('/admin/directory','DirectoriesController');
Can you have type in your cmd php artisan route:list and display here?.
| | GET|HEAD | / | | App\Http\Controllers\PagesController@index | web |
| | GET|HEAD | admin | | App\Http\Controllers\PagesController@admin | web |
| | GET|HEAD | admin/directory | directory.index | App\Http\Controllers\DirectoriesController@index | web |
| | POST | admin/directory | directory.store | App\Http\Controllers\DirectoriesController@store | web |
| | GET|HEAD | admin/directory/create | directory.create | App\Http\Controllers\DirectoriesController@create | web |
| | GET|HEAD | admin/directory/{directory} | directory.show | App\Http\Controllers\DirectoriesController@show | web |
| | PUT|PATCH | admin/directory/{directory} | directory.update | App\Http\Controllers\DirectoriesController@update | web |
| | DELETE | admin/directory/{directory} | directory.destroy | App\Http\Controllers\DirectoriesController@destroy | web |
| | GET|HEAD | admin/directory/{directory}/edit | directory.edit | App\Http\Controllers\DirectoriesController@edit | web |
| | GET|HEAD | api/user
Use like below form and check.
<form action="{{ route('directory.destroy',$directory->id) }}" method="POST" >
<a class="btn btn-primary" href="{{ route('directory.edit ',$directory->id)}}">Edit</a>
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger" >Delete </button>
</form>
<form action="{{ route('directory.destroy',$directory->id) }}" method="POST" >
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger" >
<img src="/storage/admin/delete.png"/>
</button>
</form>
Please or to participate in this conversation.