I am using FilePond for the image upload. It generates random strings for the images uploaded and is saved in database as Array.
I tried to do the following, it deletes the record but doesn't delete the files associated with it.
Since it's an array, I tried this:
foreach($this->attachments as $attachment) {
if(File::exists(storage_path($attachment))) {
Storage::delete($attachment);
}
}
Also tried this:
if(Storage::exists($this->attachments))
{
Storage::delete($this->attachments);
}
Note: I am using Filament as the admin dashboard.
The files are being saved at storage/app/public/vehicle-images
I did php artisan storage:link
, so the public folder shows ``public/storage/vehicle-images```