I want to delete a model but it might have related records in another model when will prohibit me doing so. How can I best use the already defined relationships to check if delete will be successful? Potentially there could also be non-relationship reasons for not allowing a delete.
Once I have determined my error messages how can I best store them and pass them on to the front-end? beforeDelete()
only returns true or false but I of course need to provide user with friendly error messages saying WHY the record can't be deleted...
Relationship already defined is for example:
public function getPhonenumbers() {
return $this->hasMany(Phonenumber::class, ['ph_contactID' => 'contactID']);
}