argument('email'); // check if username is really email if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $this->error($email . ' is not a valid e-mail!'); return; } // ask for password do { $password = $this->secret('Password'); $passwordAgain = $this->secret('Password again'); if ($password !== $passwordAgain) { $this->error('Passwords does not match'); } } while ($passwordAgain !== $password || strlen($password) === 0); // ask for role $roles = UserRoles::getSimple(); do { $role = $this->ask('Role (default ' . User::ROLE_ADMIN . '): ', User::ROLE_ADMIN); // check if given role is valid if (!in_array($role, $roles)) { $this->error('Invalid role specified. valid roles are: ' . implode(', ', $roles)); } } while (!in_array($role, $roles)); // create new user $user = new User(); $user->username = $user->email = $email; $user->password = Hash::make($password); $user->role = $role; $user->save(); $this->info('User ' . $email . ' successfully created.'); } }