Skip to content

Commit 5945c8f

Browse files
fix: delete project memberships automatically when project or member is deleted
1 parent 7cc34ca commit 5945c8f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

php-classes/Laddr/PeopleRequestHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,12 @@ public static function handleRecordRequest(\ActiveRecord $Member, $action = fals
6868
return parent::handleRecordRequest($Member, $action);
6969
}
7070
}
71+
72+
protected static function onBeforeRecordDestroyed(\ActiveRecord $Person)
73+
{
74+
// delete project memberships
75+
foreach ($Person->ProjectMemberships as $ProjectMembership) {
76+
$ProjectMembership->destroy();
77+
}
78+
}
7179
}

php-classes/Laddr/ProjectsRequestHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,12 @@ protected static function applyRecordDelta(ActiveRecord $Project, $requestData)
255255

256256
return parent::applyRecordDelta($Project, $requestData);
257257
}
258+
259+
protected static function onBeforeRecordDestroyed(ActiveRecord $Project)
260+
{
261+
// delete project memberships
262+
foreach ($Project->Memberships as $ProjectMembership) {
263+
$ProjectMembership->destroy();
264+
}
265+
}
258266
}

0 commit comments

Comments
 (0)