/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public static function index($id, array $data = ['y' => 0])
 {
     $challenge = Challenge::find($id);
     $challenge_name = $challenge->name;
     $group = Group::where('challenge_id', '=', $id)->get()->toArray();
     $teamRound = Round::where('challenge_id', '=', $id)->orderBy('team_id', 'DESC')->get()->toArray();
     $countTeamRound = count($teamRound);
     $countGroup = count($group) + $data['y'];
     $div = $countTeamRound / $countGroup;
     $p = 0;
     for ($i = $data['y']; $i <= count($teamRound) - 1; $i++) {
         if (!Groupsta::where('round_id', '=', $teamRound[$i]['id'])->first()) {
             Groupsta::create(['round_id' => $teamRound[$i]['id'], 'group_id' => $group[$p]['id'], 'challenge_id' => $id]);
         }
         if ($i == $countGroup - 1) {
             GroupstaController::index($id, $data = ['y' => $i + 1]);
             break;
         }
         $p++;
     }
     if (!ENV('DEVELOP')) {
         $data = GroupstaController::pagination($id);
         $dataG = [];
         $dataG += ['' => '-- Seleciona Grupo --'];
         $datagro = Group::where('challenge_id', '=', $id)->lists('name', 'id')->toArray();
         $dataG += $datagro;
         return view('groupsstage.index', compact('data', 'challenge_name', 'dataG'));
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($id)
 {
     $challenge = Challenge::find($id);
     $name_challenge = $challenge->name;
     $cha = Challenge::listGroup();
     $pag = $this->pagination($id);
     return view('stages.index', compact('pag', 'cha', 'id', 'name_challenge'));
 }
 public function guess(Request $request, $id)
 {
     $challenge = Challenge::find($id);
     if (strtolower($request->input('guess')) == $challenge->answer) {
         $this->output['data']['correct'] = 1;
     } else {
         $this->output['data']['correct'] = 0;
     }
     return $this->response();
 }
 public static function index($id, array $data = ['y' => 0, 'time_start' => 0, 'time_end' => 0])
 {
     $challenge = Challenge::find($id);
     $challenge_name = $challenge->name;
     $cha = Challenge::listGroup();
     $flag = true;
     //        if(!Round::where('challenge_id','=',$id)->first()){
     $stage = Stage::where('challenge_id', '=', $id)->where('back', '=', 0)->where('active', '=', 1)->get()->toArray();
     $team = Team::where('challenge_id', '=', $id)->where('active', '=', 1)->orderBy('id', 'RAND()')->get()->toArray();
     $numStage = count($stage) + $data['y'];
     if ($data['time_start'] == 0 && $data['time_end'] == 0) {
         $date = new DateTime(Settings::ScheTrial());
         $time = 0;
         $pag = false;
         $hora_start = $date->format('H:i:s');
         $hora_end = date('H:i:s', strtotime($date->format('H:i:s') . '+' . $time . ' minute'));
         $date_end = new DateTime($hora_end);
         $time_dos = Settings::durationTrial();
         $hora_start = strtotime('+' . $time_dos . ' minute', strtotime($date_end->format('H:i:s')));
         $hora_start = date('H:i:s', $hora_start);
     } else {
         $date = new DateTime($data['time_start']);
         $time = 0;
         $pag = false;
         $hora_start = $date->format('H:i:s');
         $hora_end = date('H:i:s', strtotime($date->format('H:i:s') . '+' . $time . ' minute'));
         $date_end = new DateTime($hora_end);
         $time_dos = Settings::durationTrial();
         $hora_start = strtotime('+' . $time_dos . ' minute', strtotime($date_end->format('H:i:s')));
         $hora_start = date('H:i:s', $hora_start);
     }
     $p = 0;
     for ($i = $data['y']; $i <= count($team) - 1; $i++) {
         if (!Round::where('team_id', '=', $team[$i]['id'])->first()) {
             Round::create(['team_id' => $team[$i]['id'], 'challenge_id' => $team[$i]['challenge_id'], 'schedule_start' => $hora_end, 'schedule_end' => $hora_start, 'stage_id' => $stage[$p]['id']]);
         }
         if ($i == $numStage - 1) {
             RoundController::index($id, $data = ['y' => $i + 1, 'time_start' => $hora_start, 'time_end' => $hora_end]);
             break;
         }
         $p++;
     }
     //        }
     if (!ENV('DEVELOP')) {
         $pag = RoundController::pagination($id);
         $flag = true;
         return view('round.index', compact('flag', 'pag', 'cha', 'challenge_name', 'id'));
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($id)
 {
     $team = Team::where('challenge_id', '=', $id)->get();
     $group = Group::where('challenge_id', '=', $id)->get();
     $array = [];
     if (count($team) < 24) {
         $array += ['message' => 'Solo Puedes crear 4 grupos tienes ' . count($group)];
     } else {
         if (count($team) >= 24) {
             $array += ['message' => 'Solo Puedes crear 8 grupos tienes ' . count($group)];
         }
     }
     $datArray = $array;
     $stage = Stage::where('challenge_id', '=', $id)->lists('name', 'id');
     $challenge = Challenge::find($id);
     $name_challenge = $challenge->name;
     $cha = $id;
     $pag = $this->pagination($id);
     return view('groups.index', compact('stage', 'pag', 'cha', 'name_challenge', 'datArray'));
 }
Esempio n. 6
0
 public function getEntries($challengeType, $challenge_id)
 {
     try {
         $userToken = JWTAuth::parseToken()->authenticate();
         $signed_in = true;
     } catch (\Exception $e) {
         $signed_in = false;
     }
     $challenge = Challenge::find($challenge_id);
     $entries = $challenge->entries;
     if ($entries) {
         foreach ($entries as $entry) {
             $user = $entry->user;
             unset($entry->challenge_id);
             unset($entry->created_at);
             unset($entry->updated_at);
             unset($entry->user);
             $entry->userPic = $user->userPic;
             $entry->userName = $user->name;
             $entry->category = $challenge->isWeekly ? 'weekly' : 'monthly';
             $entry->likes = $entry->likesCount();
             if ($signed_in) {
                 $likes = Like::where('user_id', $userToken->id)->get();
                 foreach ($likes as $like) {
                     if ($like->entry_id == $entry->id) {
                         $entry->liked = true;
                     } else {
                         $entry->liked = false;
                     }
                 }
             }
         }
         return $challenge;
     } else {
         return false;
     }
 }
 /**
  *   Increments the challenges failed counter
  *
  *   @param int $challenge_id
  *
  *   @return void
  */
 public function incrementFailCounter($challenge_id)
 {
     $challenge = Challenge::find($challenge_id);
     $challenge->fail_counter += 1;
     $challenge->save();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request)
 {
     $d = Challenge::find($request->id);
     $d->delete();
     $pag = $this->pagination();
     return view('challenge.index', compact('pag'));
 }
 public function incrementTimeTwo(array $data)
 {
     if ($data['flag']) {
         $data_challenge = Challenge::find($data['challenge_id']);
         $date = new DateTime($data['time_start']);
         $time = $data['time_durat'];
         $hora_start = $date->format('H:i:s');
         $hora_end = date('H:i:s', strtotime($date->format('H:i:s') . '+' . $time . ' minute'));
         $time_two = $data_challenge->duration;
         $hora_end_two = date('H:i:s', strtotime($hora_end . '+' . $time_two . ' minute'));
         $data = ['hora_star' => $hora_end, 'hora_end' => $hora_end_two];
     } else {
         $date = new DateTime($data['time_start']);
         $time = $data['time_durat'];
         $hora_start = $date->format('H:i:s');
         $hora_end = date('H:i:s', strtotime($date->format('H:i:s') . '+' . $time . ' minute'));
         $data = ['hora_star' => $hora_start, 'hora_end' => $hora_end];
     }
     return $data;
 }
Esempio n. 10
0
 public static function FindCombat($id)
 {
     $data = Con::pagination($id);
     $challenge = Challenge::find($id);
     $challenge_name = $challenge->name;
     foreach ($data as $d) {
         $data = Groupsta::where('group_id', '=', $d['id'])->select('round_id')->get()->toArray();
         $arrayBuild = CombatRoundController::buildArray($data);
         $valore = CombatRoundController::funPru($arrayBuild);
         $dataGroup = Group::find($d['id']);
         foreach ($valore as $val) {
             $dat = CombatRound::where('group_id', '=', $d['id'])->where('versus_one', '=', $val['0'])->where('versus_two', '=', $val['1'])->where('challenge_id', '=', $id)->get();
             if (count($dat) <= 0) {
                 CombatRound::create(['group_id' => $d['id'], 'stage_id' => $dataGroup->stage_id, 'versus_one' => $val['0'], 'versus_two' => $val['1'], 'challenge_id' => $d['challenge_id']]);
             }
         }
     }
     $data = CombatRoundController::getRoundInfo($id);
     dd($data);
     if (!ENV('DEVELOP')) {
         return view('combatround.index', compact('data', 'challenge_name'));
     }
 }