F
Filament13mo ago
Stfn

DeleteAction, delete items in public/storage?

Hey! I cant seem to find a way, for the DeleteAction to also delete a file from Public/storage.. Am i overlooking something? Context: The system is a upload/download system, where i want to be able to delete certain files, after i've downloaded them. I can however not seem to make a good way to use the DeleteAction to do this
Solution:
Don’t use the action to delete the file. Use a model observer. Let the model delete the file.
Jump to solution
13 Replies
Solution
awcodes
awcodes13mo ago
Don’t use the action to delete the file. Use a model observer. Let the model delete the file.
awcodes
awcodes13mo ago
Will also be easier when dealing with soft deletes if you’re using them.
Stfn
StfnOP13mo ago
I will look into it, Thank you!
awcodes
awcodes13mo ago
It’s laravel thing though, not a Filament thing. 🙂 I do it in the curator plugin so maybe you can use that as an example.
awcodes
awcodes13mo ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Stfn
StfnOP13mo ago
Awesome! Thanks! im quite new to PHP, so thanks for nudging me in the right direction (Y)
retool
retool13mo ago
Using Curator on Infolist Builder @awcodes hey awcodes, thanks for all your work on curator - its incredible 🙂 is there an infolist component for it or a simple way to adapt it curator and glide seem to work on id and infolist seems to take a url approach im going to work on a closure solution but though I woudl double check before going too far with it
awcodes
awcodes13mo ago
if it's a relationship you could just ImageEntry::make('featured_image.path')
retool
retool13mo ago
yes it is 🙂 thank you!
awcodes
awcodes13mo ago
you may need to pass the disk to the ImageEntry too.
retool
retool13mo ago
ok ill test it now
Cyrillus Dodi
Cyrillus Dodi5mo ago
What if it's not relationship, let's say like from an array?
toeknee
toeknee5mo ago
Please open a new topic with more details on your approach.

Did you find this page helpful?