Beispiel #1
0
 /**
  * Create a new user.
  *
  * @param  \Orchestra\Contracts\Foundation\Listener\Account\ProfileCreator  $listener
  * @param  array  $input
  *
  * @return mixed
  */
 public function store(Listener $listener, array $input)
 {
     $password = Arr::get($input, 'password', Str::random(5));
     $validation = $this->validator->on('register')->with($input);
     // Validate user registration, if any errors is found redirect it
     // back to registration page with the errors
     if ($validation->fails()) {
         return $listener->createProfileFailedValidation($validation->getMessageBag());
     }
     $user = Foundation::make('orchestra.user');
     try {
         $this->saving($user, $input, $password);
     } catch (Exception $e) {
         return $listener->createProfileFailed(['error' => $e->getMessage()]);
     }
     return $this->notifyCreatedUser($listener, $user, $password);
 }