We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Confirm/Deny: Not all model events fired on magic_getter->delete(); (Sanity check)

Can anyone explain why this:

$parent = Parent::findFirstById($id);
$parent->getChildren()->delete();

WILL NOT fire a beforeValidation() event...

as this does (tested):

$parent = Parent::findFirstById($id);
foreach( $parent->getChildren() as $child) {
    $child->delete();
}


34.6k
Accepted
answer

beforeValidation IS ONLY for insert/update operations, you can use beforeDelete there



47.7k