예제 #1
0
 /**
  * @param ReadNotification $command
  * @return Notification
  * @throws \Flarum\Core\Exceptions\PermissionDeniedException
  */
 public function handle(ReadNotification $command)
 {
     $actor = $command->actor;
     if ($actor->isGuest()) {
         throw new PermissionDeniedException();
     }
     $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]);
     return $notification;
 }
예제 #2
0
 /**
  * @param ReadNotification $command
  * @return Notification
  * @throws \Flarum\Core\Exceptions\PermissionDeniedException
  */
 public function handle(ReadNotification $command)
 {
     $actor = $command->actor;
     if ($actor->isGuest()) {
         throw new PermissionDeniedException();
     }
     $notification = Notification::where('user_id', $actor->id)->findOrFail($command->notificationId);
     $notification->read();
     $notification->save();
     return $notification;
 }
예제 #3
0
 /**
  * Restore a notification for all users.
  *
  * @param Blueprint $blueprint
  * @return void
  */
 public function restore(Blueprint $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]);
 }