/** * Create a new user. * * @param object $account * @return \Gladiator\Models\User */ public function create($account) { $user = new User(); $user->id = $account->id; $user->role = isset($account->role) ? $account->role : null; $user->save(); return $user; }
/** * Execute the console command. * * @return mixed */ public function handle() { $email = $this->argument('email'); $role = $this->option('role'); if (!match_email_domain($email)) { return $this->comment(PHP_EOL . $email . ' is invalid. Admin or Staff require a DoSomething.org email.' . PHP_EOL); } $northstarUser = User::hasNorthstarAccount('email', $email); if (is_null($northstarUser)) { return $this->comment(PHP_EOL . 'No user found on Northstar with email: ' . $email . '. Create an account at https://dosomething.org.' . PHP_EOL); } $gladiatorUser = User::find($northstarUser->id); if (is_null($gladiatorUser)) { $user = new User(); $user->id = $northstarUser->id; $user->role = $role; $user->save(); return $this->comment(PHP_EOL . $email . ' added as a new "' . $role . '" user with id: ' . $northstarUser->id . PHP_EOL); } return $this->comment(PHP_EOL . $email . ' already exists as a user in Gladiator with a role of "' . $gladiatorUser->role . '"!' . PHP_EOL); }