read comment working
This commit is contained in:
parent
583daa1759
commit
39fc379541
12 changed files with 125 additions and 78 deletions
|
|
@ -1,16 +1,26 @@
|
|||
<?php
|
||||
|
||||
return function ($group, $notificationId) {
|
||||
$notifications = Yaml::decode($this->notifications()->value());
|
||||
return function($notificationId) {
|
||||
|
||||
try {
|
||||
$notifications[$group][$notificationId]['isRead'] = true;
|
||||
$notifications = $this->notifications()->isNotEmpty()
|
||||
? Yaml::decode($this->notifications()->value())
|
||||
: [];
|
||||
|
||||
$newNotification = null;
|
||||
foreach ($notifications as $key => $notification) {
|
||||
if ($notification['id'] === $notificationId) {
|
||||
$notifications[$key]['isRead'] = true;
|
||||
$newNotification = $notifications[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$this->update([
|
||||
'notifications' => Yaml::encode(array_values($notifications))
|
||||
]);
|
||||
|
||||
return $newNotification;
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
||||
}
|
||||
|
||||
$this->update([
|
||||
"notifications" => $notifications
|
||||
]);
|
||||
return $notifications;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue