Not delete image from laravel backpack 4.0

I’m using image field in laravel backpack 4.0, it upload image without problems. When I delete it from ‘delete button’, it delete register, but not image file from my local folder. I’m checked the answer from backpack for laravel deleting image , but It no fix my issue.

My config/filesystem:

'disks' => [

'local' => [
'driver' => 'local',
'root' => storage_path('app'),

'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',

's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),


My Model code:

public function setImageAttribute($value)
$attribute_name = "image";
$disk = config('backpack.base.root_disk_name'); // or use your own disk, defined in config/filesystems.php
$destination_path = env('FOLDER_PUBLIC')."/uploads/medias"; // path relative to the disk above

// if the image was erased
if ($value==null) {
// delete the image from disk

// set null in the database column
$this->attributes[$attribute_name] = null;

// if a base64 was sent, store it in the db
if (starts_with($value, 'data:image'))
// 0. Make the image
$image = Image::make($value)->encode('jpg', 90);
// 1. Generate a filename.
$filename = rand ( 10000 , 99999 ).'-'.strtolower(trim(preg_replace('/[s-]+/', '-', preg_replace('/[^A-Za-z0-9-]+/', '-', preg_replace('/[&]/', 'and', preg_replace('/[']/', '', iconv('UTF-8', 'ASCII//TRANSLIT', $this->title))))), '-')).'.jpg';

// 2. Store the image on disk.
Storage::disk($disk)->put($destination_path.'/'.$filename, $image->stream());
// 3. Save the public path to the database
// but first, remove "public/" from the path, since we're pointing to it from the root folder
// that way, what gets saved in the database is the user-accesible URL
$public_destination_path = Str::replaceFirst(env('FOLDER_PUBLIC').'/', '', $destination_path);
$this->attributes[$attribute_name] = $public_destination_path.'/'.$filename;
public static function boot()

static::deleting(function($obj) {


I have tried to change:




But it not working too,

Can you help to me ?

Sorry for my english

from Newest questions tagged laravel-5 – Stack Overflow

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.