/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $userData = [];
     $userData['email'] = $this->ask('What is the email for the user?');
     $userData['first_name'] = $this->ask('First name?');
     $userData['last_name'] = $this->ask('Last name?');
     $userData['display_name'] = $this->ask('Display name?');
     $userData['password'] = $this->secret('What is the password for the user?');
     $userData['password_confirmation'] = $this->secret('Confirm password');
     $validator = Validator::make($userData, User::$rules);
     if ($validator->fails()) {
         $messages = $validator->errors()->getMessages();
         foreach ($messages as $message) {
             if (isset($message[0])) {
                 $this->error($message[0]);
                 echo "\n";
             }
         }
         $this->info('Try running ' . $this->name . ' again.');
     } else {
         if (count(User::all()) == 0) {
             $userData['owner'] = true;
         }
         $userData['password'] = Hash::make($userData['password']);
         User::create($userData);
         $this->info("User created.");
     }
 }
Beispiel #2
0
 public function update(array $attributes = [])
 {
     //There's one user and they're not the owner of the site yet.
     //Or the owner is giving ownership to another user.
     if (array_key_exists('owner', $attributes)) {
         if (count(User::all()) == 1 && $this->owner == 0 || $this->owner) {
             $attributes['owner'] = true;
         } else {
             $attributes['owner'] = false;
         }
     } else {
         if ($this->owner) {
             $attributes['owner'] = true;
         } else {
             $attributes['owner'] = false;
         }
     }
     parent::update($attributes);
 }
 /**
  * Display a listing of users
  *
  * @return Response
  */
 public function index()
 {
     $users = User::all();
     $pageTitle = 'Users';
     return view('users.index', compact('users', 'pageTitle'));
 }