Support the ongoing development of →
Eloquent Views Blade
Last updated 10 months ago.

Instead of overwriting delete() method, you could use model event as described here:

Image::deleted(function ($image)
    // delete media

Notice I used deleted event and not deleting. I believe it's safer to delete record first and then the media.

Last updated 10 months ago.

Also, I don't think that technically you aren't actually get the file in question, perhaps just the path to it.

You might need to do something like:


Although it is a little difficult to say without seeing the rest of your code.

Last updated 10 months ago.

The file deletion part works fine T2, the problem is that the parent object (in this case $board) gets deleted along with the $media object..

Which, I found out.. my ON DELETE was set to CASCADE on the database. I feel stupid ... haha

Anyways.. let it be archived in case someone else faces the same problem.

Last updated 10 months ago.

Sign in to participate in this thread!


Your banner here too?

raphadko raphadko Joined 13 Jul 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.