'Laravel deleting with whereIn, not working boot deleting in Model
when deleting through whereIn, the boot method deleting in the Model does not work, when I delete through foreach everything is ok, is there a solution? Controller
$objects = Tutorial::whereIn('id', $request->get('objects'))->delete();
Model (Tutorial)
public static function boot()
{
parent::boot();
static::saving(function($model)
{
$model->user_id = auth()->id();
});
static::deleting(function ($model){
$model->clearMediaCollection('media');
} );
}
If deleting with Foreach boot deleting is work Example:
foreach($objects as $object){
$object->delete();
// boot in model work!
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
