read comment working
This commit is contained in:
parent
583daa1759
commit
39fc379541
12 changed files with 125 additions and 78 deletions
|
|
@ -1,25 +1,22 @@
|
|||
<?php
|
||||
|
||||
return function($project, $notificationId) {
|
||||
$projectManagers = $project->managers()->toUsers();
|
||||
|
||||
foreach ($projectManagers as $user) {
|
||||
try {
|
||||
$notifications = $user->notifications()->isNotEmpty()
|
||||
? Yaml::decode($user->notifications()->value())
|
||||
: [];
|
||||
|
||||
foreach ($notifications as $key => $notification) {
|
||||
if ($notification['id'] === $notificationId) {
|
||||
unset($notifications[$key]);
|
||||
}
|
||||
return function($notificationId) {
|
||||
$user = kirby()->user();
|
||||
try {
|
||||
$notifications = $user->notifications()->isNotEmpty()
|
||||
? Yaml::decode($user->notifications()->value())
|
||||
: [];
|
||||
|
||||
foreach ($notifications as $key => $notification) {
|
||||
if ($notification['id'] === $notificationId) {
|
||||
unset($notifications[$key]);
|
||||
}
|
||||
|
||||
$user->update([
|
||||
'notifications' => Yaml::encode(array_values($notifications))
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
||||
}
|
||||
|
||||
$user->update([
|
||||
'notifications' => Yaml::encode(array_values($notifications))
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue