F
Filamentβ€’14mo ago
wandiaprianto

on edit/delete how to delete file?

No description
14 Replies
Dennis Koch
Dennis Kochβ€’14mo ago
Again: You didn't provide any information other than a screenshot.
wandiaprianto
wandiapriantoOPβ€’14mo ago
that information is on title "how to delete file on edit/delete?"
Dennis Koch
Dennis Kochβ€’14mo ago
What file? Under which condition do you want to delete it? We don't know anything about your code πŸ€·β€β™‚οΈ You expect us to know your system from a one liner.
wandiaprianto
wandiapriantoOPβ€’14mo ago
i want to delete file too, not just a record
Dennis Koch
Dennis Kochβ€’14mo ago
This is as helpful as if I respond: Files can be deleted via Storage::delete()
Dennis Koch
Dennis Kochβ€’14mo ago
Did you read that part of FileUpload docs?
No description
wandiaprianto
wandiapriantoOPβ€’14mo ago
i have done using Storage::delete() but still not deleted
Dennis Koch
Dennis Kochβ€’14mo ago
Then there is probably an issue, but I can't help you if you just say "I've done it"
wandiaprianto
wandiapriantoOPβ€’14mo ago
Tables\Actions\DeleteAction::make()
->before(function ($record) {
Storage::delete($record->image);
})
Tables\Actions\DeleteAction::make()
->before(function ($record) {
Storage::delete($record->image);
})
the file won't be deleted
Dennis Koch
Dennis Kochβ€’14mo ago
- Any error? Return value of the method? - How does your FileUpload field look like? - What the value of $record->image? - Where is your file stored?
wandiaprianto
wandiapriantoOPβ€’14mo ago
- The problem is that no error message appears, delete success, but won't delete the file - my file stored at storage\app\public\car-kind-attachments\NLW7uwIITF5gUouMdCMFoeQ5LaO2jx-metaMjAyMzA3MDQwOTA5MDUucG5n-.png - the value of $record->image is car-kind-attachments/CMcvHeYyxlFxPMQZHlrYkwuQmUTKng-metaMjAyMzA3MDQwOTA5MDUucG5n-.png - this is my FileUpload code: Forms\Components\FileUpload::make('image')->label('Image')->directory('car-kind-attachments')->image(),
Vp
Vpβ€’14mo ago
Storage::disk('public')->delete($record->image)
wandiaprianto
wandiapriantoOPβ€’14mo ago
okay, i'll try this work for me, thankyou πŸ˜€ thankyou all @Dennis Koch @Vp
Want results from more Discord servers?
Add your server