2024-10-29 16:13:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
2024-10-30 12:15:28 +01:00
|
|
|
return function ($item) {
|
2024-10-29 16:13:07 +01:00
|
|
|
foreach (kirby()->users()->not($this) as $otherUser) {
|
|
|
|
|
try {
|
|
|
|
|
$notifications = $otherUser->notifications()->isNotEmpty()
|
|
|
|
|
? Yaml::decode($otherUser->notifications()->value())
|
|
|
|
|
: [];
|
|
|
|
|
|
2024-10-30 12:15:28 +01:00
|
|
|
$notifications[] = $item->toArray();
|
2024-10-29 16:13:07 +01:00
|
|
|
|
|
|
|
|
$otherUser->update([
|
|
|
|
|
'notifications' => $notifications
|
|
|
|
|
]);
|
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
|
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|