/** * @param ReadAllNotifications $command * * @return void */ public function handle(ReadAllNotifications $command) { $actor = $command->actor; if ($actor->isGuest()) { throw new PermissionDeniedException(); } $this->notifications->markAllAsRead($actor); }
/** * Get the notification results, ready to be serialized and assigned to the * document response. * * @param JsonApiRequest $request * @param Document $document * @return \Illuminate\Database\Eloquent\Collection * @throws PermissionDeniedException */ protected function data(JsonApiRequest $request, Document $document) { $actor = $request->actor; if ($actor->isGuest()) { throw new PermissionDeniedException(); } $actor->markNotificationsAsRead()->save(); return $this->notifications->findByUser($actor, $request->limit, $request->offset)->load($request->include); }