Thanks, that's what I was looking for, I have not used behaviors yet.
While researching beforeDelete I came across the hasAny() function
which also helps.
My current way of doing things also displays a list of all the records
("books") that belongTo the record that has been attempted to be
delete
Depending on your database, you may be able to use constraints on the
foreign keys of your database ("ON DELETE RESTRICT"), however that's a
responsive check rather than pro-active. In your situation, you may find
creating a behavior would be beneficial. The behavior would run the checks
on the bef
In the case where If I have a one to many relationship like Authors-
>Books and I would like to delete an author - but only if this author
has no books - is there a buiilt-in way to check?
I find that I run into this situation a lot (every time a table has a
foreign key), and at the moment manual