notifications()->isNotEmpty() ? Yaml::decode($this->notifications()->value()) : []; $newNotification = null; foreach ($notifications as $key => $notification) { if (!isset($notification['id'])) continue; 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 new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1); } };