Пример #1
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $input = ['name' => trim($this->argument('name')), 'email' => trim($this->argument('email')), 'password' => $this->option('password')];
     if (is_null($input['name'])) {
         $this->error('You must set a username as the first argument.');
         return;
     }
     if (is_null($input['email'])) {
         $this->error('You must set an email address as the first argument.');
         return;
     }
     $val = Validator::make($input, ['name' => ['required', 'unique:' . Auth::getTableName('users') . ',name'], 'email' => ['required', 'email', 'unique:' . Auth::getTableName('users') . ',email']]);
     if ($val->fails()) {
         $errors = array_values($val->errors()->all());
         $this->error(implode("\n", $errors));
         return;
     }
     Auth::createUser($input, $this->option('activate'), !$this->option('suppress'));
     $this->comment('Created a user.');
     $this->output->writeln(' Username:      <info>' . $input['name'] . '</info>');
     $this->output->writeln(' Email Address: <info>' . $input['email'] . '</info>');
     $this->output->writeln(' Password:      <info>' . $input['password'] . '</info>');
     $this->output->writeln(' Activated:     <info>' . ($this->option('activate') ? 'Yes' : 'No') . '</info>');
     $this->output->writeln('');
     return;
 }