change notifications structure from object to array

This commit is contained in:
isUnknown 2024-10-30 12:15:28 +01:00
parent 0d25794b87
commit 20824983a6
8 changed files with 64 additions and 50 deletions

View file

@ -1,17 +1,13 @@
<?php
return function ($group, $item) {
return function ($item) {
foreach (kirby()->users()->not($this) as $otherUser) {
try {
$notifications = $otherUser->notifications()->isNotEmpty()
? Yaml::decode($otherUser->notifications()->value())
: [];
if (!isset($notifications[$group])) {
$notifications[$group] = [];
}
$notifications[$group][$item->id()] = $item->toArray();
$notifications[] = $item->toArray();
$otherUser->update([
'notifications' => $notifications