26 lines
744 B
PHP
26 lines
744 B
PHP
|
|
<?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]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$user->update([
|
||
|
|
'notifications' => Yaml::encode(array_values($notifications))
|
||
|
|
]);
|
||
|
|
} catch (\Throwable $th) {
|
||
|
|
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|