public function store() { $input = \Input::only('subject', 'message', 'send_to_all', 'recipient'); $this->emailNotificationValidator->validate($input); //This is for admins only unless they are part of a group, then they have access to specific lists if (!\Auth::user()->isAdmin() && !\Auth::user()->hasRole('laser')) { } if ($input['send_to_all']) { if ($input['recipient'] == 'all') { if (!\Auth::user()->isAdmin()) { throw new AuthenticationException("You don't have permission to send to this group"); } $users = $this->userRepository->getActive(); } else { if ($input['recipient'] == 'laser_induction_members') { if (!\Auth::user()->hasRole('laser')) { throw new AuthenticationException("You don't have permission to send to this group"); } $users = $this->inductionRepository->getUsersForEquipment('laser'); } else { throw new NotImplementedException("Recipient not supported"); } } foreach ($users as $user) { $notification = new UserMailer($user); $notification->sendNotificationEmail($input['subject'], nl2br($input['message'])); } } else { //Just send to the current user $notification = new UserMailer(\Auth::user()); $notification->sendNotificationEmail($input['subject'], nl2br($input['message'])); } \Notification::success('Email Queued to Send'); return \Redirect::route('notificationemail.create'); }
private function userLeft($user) { $userMailer = new UserMailer($user); $userMailer->sendLeftMessage(); $this->sendSlackNotification('#trustees', $user->name . ' has left Build Brighton'); }