Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
0
 /**
  * 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]);
 }
Ejemplo n.º 3
0
 /**
  * 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]);
 }