You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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. (
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:
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
Is this correct behaviour?
The text was updated successfully, but these errors were encountered: