/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $user = new User();
     $user->username = $this->argument('username');
     $user->email = $this->argument('username') . '@spacexstats.com';
     $user->password = $this->argument('password');
     // Hashed as a mutator on the User model
     $user->key = str_random(32);
     $user->role_id = UserRole::fromString($this->argument('role'));
     if ($this->option('launchctl')) {
         $user->launch_controller_flag = true;
     }
     DB::transaction(function () use($user) {
         $user->save();
         // Associate a profile
         $profile = new Profile();
         $profile->user()->associate($user)->save();
     });
 }
 /**
  * Create a new user instance after a valid registration, also send them a welcome email.
  *
  * @param array $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = new User();
     $user->username = $data['username'];
     $user->email = $data['email'];
     $user->password = $data['password'];
     // Hashed as a mutator on the User model
     $user->key = str_random(32);
     $user->role_id = UserRole::Unauthenticated;
     DB::transaction(function () use($user) {
         $user->save();
         // Associate a profile
         $profile = new Profile();
         $profile->user()->associate($user)->save();
     });
     // Add a welcome email to the queue
     $this->mailer->welcome($user);
     return $user;
 }