laravel-ardent / ardent

Self-validating, secure and smart models for Laravel's Eloquent ORM
BSD 3-Clause "New" or "Revised" License
1.39k stars 211 forks source link

Is there a way to perform validation on delete? #304

Open IvanRibakov opened 7 years ago

IvanRibakov commented 7 years ago

I'm using soft-delete with my currency model and would like to enforce foreign key integrity by checking that regions hasMany relationship is empty before any currency is allowed to be deleted. Will validation be performed on $currency->delete() call? If not, is there a way to enforce this behaviour on the model level (to avoid replicating same logic in multiple places)?