Notifications page : mark all as read working
This commit is contained in:
parent
cdf663d4ca
commit
5c9f450539
7 changed files with 76 additions and 19 deletions
22
public/site/plugins/notifications/user-methods/readAll.php
Normal file
22
public/site/plugins/notifications/user-methods/readAll.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
return function() {
|
||||
try {
|
||||
$notifications = $this->notifications()->isNotEmpty()
|
||||
? Yaml::decode($this->notifications()->value())
|
||||
: [];
|
||||
|
||||
$newNotification = null;
|
||||
foreach ($notifications as $key => $notification) {
|
||||
$notifications[$key]['isRead'] = true;
|
||||
}
|
||||
|
||||
$updatedUser = $this->update([
|
||||
'notifications' => Yaml::encode(array_values($notifications))
|
||||
]);
|
||||
|
||||
return Yaml::decode($updatedUser->notifications()->value());
|
||||
} catch (\Throwable $th) {
|
||||
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue