Ejemplo n.º 1
0
 /**
  * Resolve user account within Northstar/Gladiator system.
  *
  * @param  array  $credentials
  * @return \Gladiator\Models\User|object
  * @throws \Gladiator\Services\Northstar\Exceptions\NorthstarUserNotFoundException
  */
 public function findUserAccount($credentials)
 {
     $northstarUser = $this->northstar->getUser($credentials['term'], $credentials['id']);
     if (!$northstarUser) {
         throw new NorthstarUserNotFoundException();
     }
     // @TODO: Can't use Repository method below because it throws exception
     // and here we just need "null" if user not found in Database. Find a
     // better fix if necessary!
     $user = User::find($northstarUser->id);
     if (!$user) {
         return $northstarUser;
     }
     return $user;
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
0
 public function saveSplit($contest, $split, $request)
 {
     $startDate = Carbon::now()->startOfDay();
     $endDate = new Carbon($request->competition_end_date);
     foreach ($split as $competitionGroup) {
         // For each split, create a competition.
         $competition = new Competition();
         $competition->contest_id = $contest->getKey();
         $competition->competition_start_date = $startDate;
         $competition->competition_end_date = $endDate->endOfDay();
         $competition->leaderboard_msg_day = $request->leaderboard_msg_day;
         $competition->rules_url = $request->rules_url;
         $contest->competitions()->save($competition);
         // For each user in this group
         foreach ($competitionGroup as $userId) {
             $user = User::find($userId);
             // Remove them from the waiting room pivot table
             $user->waitingRooms()->detach();
             // Add them to the competitions pivot table
             $user->competitions()->attach($competition->id);
         }
     }
 }