In my models I've setup boot methods so when I softdelete a record the related records are softdeleted aswell. Like this:
Company.php
protected static function boot()
{
parent::boot();
static::deleting(function($company) {
$company->department()->delete();
});
}
Department.php:
protected static function boot()
{
parent::boot();
static::deleting(function($department) {
dd('test');
});
}
So when I want to softdelete a company the departments should also be softdeleted. But when I dd in static::deleting(Department.php) this is not reached. When I dd like this:
Department.php
protected static function boot()
{
parent::boot();
dd('test');
static::deleting(function($department) {
});
}
Result is test
What am I doing wrong here?