14 protected $signature =
'admin:create {--first_name=} {--last_name=} {--email=} {--username=} {--password=}';
30 parent::__construct();
41 $first_name = $this->option(
'first_name');
42 $last_name = $this->option(
'last_name');
43 $username = $this->option(
'username');
44 $email = $this->option(
'email');
45 $password = $this->option(
'password');
47 if (($first_name==
'') || ($last_name==
'') || ($username==
'') || ($email==
'') || ($password==
'')) {
48 $this->info(
'ERROR: All fields are required.');
50 $user = new \App\Models\User;
51 $user->first_name = $first_name;
52 $user->last_name = $last_name;
53 $user->username = $username;
54 $user->email = $email;
55 $user->permissions =
'{"admin":1,"user":1,"superuser":1,"reports":1}';
56 $user->password = bcrypt($password);
59 $this->info(
'New user created');
60 $user->groups()->attach(1);
62 $this->info(
'Admin user was not created');
63 $errors = $user->getErrors();
65 foreach ($errors->all() as $error) {
66 $this->info(
'ERROR:'. $error);
__construct()
Create a new command instance.
handle()
Execute the console command.