26 lines
685 B
PHP
26 lines
685 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
return function ($group, $data) {
|
||
|
|
foreach (kirby()->users()->not($this) as $otherUser) {
|
||
|
|
try {
|
||
|
|
$notifications = $otherUser->notifications()->isNotEmpty()
|
||
|
|
? Yaml::decode($otherUser->notifications()->value())
|
||
|
|
: [];
|
||
|
|
|
||
|
|
if (!isset($notifications[$group])) {
|
||
|
|
$notifications[$group] = [];
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$data['isRead'] = false;
|
||
|
|
|
||
|
|
$notifications[$group][$data['id']] = $data;
|
||
|
|
|
||
|
|
$otherUser->update([
|
||
|
|
'notifications' => $notifications
|
||
|
|
]);
|
||
|
|
} catch (\Throwable $th) {
|
||
|
|
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|