-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
The method deleteWithRelated() only seems to work with direct relations.
So this works just fine:
parent -> child
If I $parent->deleteWithRelated() then both parent and child are soft deleted.
However, this fails:
parent -> child -> child_of_child
In this situation, only parent and child are soft deleted, while child_of_child is untouched.
The solution is to update yii2-relation-trait with the needed information:
class parent()...
{
public function relationNames()
{
return [
'child',
'child_of_child',
];
}
public function getChildOfChilds()
{
return $this->hasMany(ChildOfChild::className(), ['child_id' => 'id'])->via('Childs');
}
}
However, if I remove relationNames() in the class def and let deleteWithRelated real-time determine this, it doesn't soft delete child_of_child. (
yii2-relation-trait/RelationTrait.php
Line 461 in aa8ff00
| } else { |
Is this correct behaviour?
Metadata
Metadata
Assignees
Labels
No labels