/** * Handle the event. * * @param UserRolesChanged $event * * @return void */ public function handle(UserRolesChanged $event) { if (count($event->getAttached()) > 0 or count($event->getDetached()) > 0) { $attached = Role::whereIn('id', $event->getAttached())->pluck('name')->implode(', '); $detached = Role::whereIn('id', $event->getDetached())->pluck('name')->implode(', '); $this->notifications->create($event->getUser(), ['icon' => 'comment outline', 'body' => trans('users::core.messages.user.roles_changed', ['attached' => $attached, 'detached' => $detached]), 'from' => auth()->user()]); } }
/** * Get the recent notifications and announcements for the user. * * @param NotificationRepository $notifications * @param Request $request */ public function recent(NotificationRepository $notifications, Request $request) { $this->setContent($notifications->recent($request->user())); }