F
Filament6mo 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
11 Replies
Solution
awcodes
awcodes6mo ago
Don’t use the action to delete the file. Use a model observer. Let the model delete the file.
awcodes
awcodes6mo ago
Will also be easier when dealing with soft deletes if you’re using them.
Stfn
Stfn6mo ago
I will look into it, Thank you!
awcodes
awcodes6mo 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
awcodes6mo 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
Stfn6mo ago
Awesome! Thanks! im quite new to PHP, so thanks for nudging me in the right direction (Y)
retool
retool5mo 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
awcodes5mo ago
if it's a relationship you could just ImageEntry::make('featured_image.path')
retool
retool5mo ago
yes it is 🙂 thank you!
awcodes
awcodes5mo ago
you may need to pass the disk to the ImageEntry too.
retool
retool5mo ago
ok ill test it now