designtopack/public/site/plugins/notifications/user-methods/send.php

19 lines
No EOL
540 B
PHP

<?php
return function ($item) {
foreach (kirby()->users()->not($this) as $otherUser) {
try {
$notifications = $otherUser->notifications()->isNotEmpty()
? Yaml::decode($otherUser->notifications()->value())
: [];
$notifications[] = $item->toArray();
$otherUser->update([
'notifications' => $notifications
]);
} catch (\Throwable $th) {
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
}
}
};