/** * Handle the invite team member command. * * @param \CachetHQ\Cachet\Commands\User\InviteTeamMemberCommand $command * * @return void */ public function handle(InviteTeamMemberCommand $command) { foreach ($command->emails as $email) { $invite = Invite::create(['email' => $email]); event(new UserWasInvitedEvent($invite)); } }
/** * Handle a signup request. * * @param string|null $code * * @return \Illuminate\View\View */ public function postSignup($code = null) { if ($code === null) { throw new NotFoundHttpException(); } $invite = Invite::where('code', '=', $code)->first(); if (!$invite || $invite->is_claimed) { throw new BadRequestHttpException(); } try { dispatch(new SignupUserCommand(Binput::get('username'), Binput::get('password'), Binput::get('email'), User::LEVEL_USER)); } catch (ValidationException $e) { return Redirect::route('signup.invite', ['code' => $invite->code])->withInput(Binput::except('password'))->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.signup.failure')))->withErrors($e->getMessageBag()); } dispatch(new ClaimInviteCommand($invite)); return Redirect::route('status-page')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success'))); }