I have two models with a relationship.
So when Model A will be delete, all related Models B should be also delete.
I'm working with soft deleting.
Here my trigger in Model A:
protected static function boot()
{
parent::boot();
// Delete Relations
self::deleting(function (Customer $customer) {
$customer->contacts()->delete();
});
}
When I delete a Model A the related Models from B will not be touched. So nothing happens.
So the trigger is not working. I got no error or something else. Has anyone an idea how I should find the mistake?
Edit: The relations looks like this:
public function contacts()
{
return $this->hasMany(Contact::class);
}
and
public function customer()
{
return $this->belongsTo(Customer::class);
}
In all other cases where I use the relation it works fine.