I've got media models related to records in a videos table. If I delete a record in videos, the model in media doesn't delete.
If I go:
$videos = Video::where('set_id', $request->set_id)->delete();
I'd expect each model in media along with the file to be deleted too.
What am I doing wrong?
To determine when to delete files this package hooks into Laravel's model events. Those events won't get fired when mass deleting using the query builder.
To fix this you should delete models one by one:
Video::where('set_id', $request->set_id)->each->delete();
Keep in mind that this will fire off multiple queries.
Most helpful comment
To determine when to delete files this package hooks into Laravel's model events. Those events won't get fired when mass deleting using the query builder.
To fix this you should delete models one by one:
Keep in mind that this will fire off multiple queries.