/**
  * Display the specified resource.
  *
  * @param  \Gladiator\Models\WaitingRoom  $room
  * @return \Illuminate\Http\Response
  */
 public function show(WaitingRoom $room)
 {
     $users = [];
     $contest = Contest::find($room->contest_id);
     $ids = $room->users->pluck('id')->toArray();
     if ($ids) {
         $users = $this->repository->getAll($ids);
     }
     return view('waitingrooms.show', compact('room', 'contest', 'users'));
 }
Beispiel #2
0
 /**
  * Get a collection of Northstar users that exist on a model.
  *
  * @param  \Gladiator\Models\Competition|WaitingRoom  $model
  * @param  bool  $withReportback
  * @return \Illuminate\Support\Collection  $users
  */
 public function getModelUsers($model, $withReportback = false)
 {
     $users = $model->users;
     if (!$users) {
         return null;
     }
     $ids = $users->pluck('id')->all();
     $users = $this->userRepository->getAll($ids);
     if (!$withReportback) {
         return $users;
     }
     return $this->appendReportback($users, $this->getCampaignParameters($model));
 }
 /**
  * Get collection of all users or set of users by ids from cache or
  * default to alternate respository lookup.
  *
  * @param  array $ids Northstar IDs
  * @return \Illuminate\Support\Collection
  */
 public function getAll(array $ids = [])
 {
     // @TODO: This is messy and needs another pass to simplify.
     if ($ids) {
         $users = $this->retrieveMany($ids);
         if (!$users) {
             $users = $this->repository->getAll($ids);
             if ($users->count()) {
                 $group = $users->keyBy('id')->all();
                 $this->storeMany($group);
             }
         } else {
             $users = $this->resolveMissingUsers($users);
             $users = collect(array_values($users));
         }
         return $users;
     }
     // @TODO: find a better way to retrieve all from cache.
     // Will resort to just passing off to alternate repository
     // and grabbing everything from Northstar without caching.
     $users = $this->repository->getAll();
     return $users;
 }