/** * @param ReadNotification $command * @return \Flarum\Core\Notification * @throws \Flarum\Core\Exception\PermissionDeniedException */ public function handle(ReadNotification $command) { $actor = $command->actor; $this->assertRegistered($actor); $notification = Notification::where('user_id', $actor->id)->findOrFail($command->notificationId); Notification::where(['user_id' => $actor->id, 'type' => $notification->type, 'subject_id' => $notification->subject_id])->update(['is_read' => true]); $notification->is_read = true; return $notification; }
/** * Restore a notification for all users. * * @param BlueprintInterface $blueprint * @return void */ public function restore(BlueprintInterface $blueprint) { Notification::where($this->getAttributes($blueprint))->update(['is_deleted' => false]); }
/** * Mark all of a user's notifications as read. * * @param User $user * * @return void */ public function markAllAsRead(User $user) { Notification::where('user_id', $user->id)->update(['is_read' => true]); }