/**
  * 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'));
     }
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Group::index(1);
     Group::index(2);
     Group::index(3);
     Group::index(4);
     Group::index(5);
     Group::index(7);
     Group::index(8);
 }