when trying to delete an image i need to remove it completely form the disk
function:
public function setUrlAttribute($value)
{
$attribute_name = "url";
$disk = "public";
$destination_path = "uploads/equipos";
if ($value==null) {
// delete the image from disk
Storage::disk($disk)->delete($this->url); //<---- fix here
// set null in the database column
$this->attributes[$attribute_name] = null;
}
when deleting the image, nothing changes, need help deleting the image physically from the disk.
TLDR; check for destination files permissions after upload, also try to
dump($this->url)
before deleting, to ensure the correct path from your disk is being usedExample:
As long as you have your field correctly defined, backpack should be able to manage everything automatically. For example, dealing with client images, I have this as the field:
Then, in the model
And that's all, backpack takes care of everything.
The only thing you need to take into account is, if you delete the model (deleting a client in my example), you also need to take care of the files deleting by yourself. This can be done in the
boot
method of the model, with adeleting
event.As you pass it the
$disk
and the fieldvalue
, it will delete the file without problems, no need to specify the path, as it will be included in the$value