create and delete notification for a project working

This commit is contained in:
isUnknown 2025-01-10 15:38:57 +01:00
parent 8c6e21c707
commit 9222069ef5
9 changed files with 105 additions and 52 deletions

View file

@ -1,10 +1,10 @@
<?php
return function($project, $notificationId) {
foreach ($project->managers() as $projectManager) {
foreach (kirby()->users() as $user) {
try {
$notifications = $projectManager->notifications()->isNotEmpty()
? Yaml::decode($projectManager->notifications()->value())
$notifications = $user->notifications()->isNotEmpty()
? Yaml::decode($user->notifications()->value())
: [];
foreach ($notifications as $key => $notification) {
@ -13,7 +13,7 @@ return function($project, $notificationId) {
}
}
$projectManager->update([
$user->update([
'notifications' => Yaml::encode(array_values($notifications))
]);
} catch (\Throwable $th) {