Exemplo n.º 1
0
 public function handle($command)
 {
     $token = EmailToken::find($command->token)->first();
     if (!$token) {
         throw new InvalidConfirmationTokenException();
     }
     $user = $token->user;
     $user->changeEmail($token->email);
     if (!$user->is_activated) {
         $user->activate();
     }
     event(new UserWillBeSaved($user, $command));
     $user->save();
     $this->dispatchEventsFor($user);
     $token->delete();
     return $user;
 }