private function setRound() { $start_stage_id = Stage::getStartStage()->id; $next_stage_id = $start_stage_id; while ($next_stage_id) { $games = array(); $this->labels[] = Stage::find($next_stage_id)->name; $next_stage_id_tmp = Stage::find($next_stage_id)->next_stage; foreach (Game::whereRaw('stage_id = ?', array($next_stage_id))->orderBy('stage_game_num', 'ASC')->get() as $value) { $score1 = $value->team1_goals; $score2 = $value->team2_goals; if ($value->team1_kick_at_goal != null && $value->team2_kick_at_goal != null) { $score1 .= " (" . $value->team1_kick_at_goal . ")"; } if ($value->team1_kick_at_goal != null && $value->team2_kick_at_goal != null) { $score2 .= " (" . $value->team2_kick_at_goal . ")"; } $games[] = array(array('name' => $value->team1()->first() ? $value->team1()->first()->name : "-", 'id' => $value->team1_id, 'score' => $score1), array('name' => $value->team2()->first() ? $value->team2()->first()->name : "-", 'id' => $value->team2_id, 'score' => $score2)); } $this->rounds[] = $games; if ($next_stage_id_tmp == null) { $gamme = Game::whereRaw('stage_id = ? && stage_game_num = 1', array($next_stage_id))->first(); //Vinqueur $this->rounds[] = array(array(array('name' => $gamme->winner()->first() ? $gamme->winner()->first()->name : "-", 'id' => $gamme->winner_id))); } $next_stage_id = $next_stage_id_tmp; } ///////////////////////////////////////////////// //******************* 3e place ****************// ///////////////////////////////////////////////// $stage_third = Stage::getThirdStage()->id; $gamme_third = Game::whereRaw('stage_id = ?', array($stage_third))->first(); if ($gamme_third != null) { $score1 = $value->team1_goals; $score2 = $value->team2_goals; if ($gamme_third->team1_kick_at_goal != null && $gamme_third->team2_kick_at_goal != null) { $score1 .= " (" . $gamme_third->team1_kick_at_goal . ")"; } if ($gamme_third->team1_kick_at_goal != null && $gamme_third->team2_kick_at_goal != null) { $score2 .= " (" . $gamme_third->team2_kick_at_goal . ")"; } $this->third[] = array(array(array('name' => $gamme_third->team1()->first() ? $gamme_third->team1()->first()->name : "-", 'id' => $gamme_third->team1_id, 'score' => $score2), array('name' => $gamme_third->team2()->first() ? $gamme_third->team2()->first()->name : "-", 'id' => $gamme_third->team2_id, 'score' => $score2))); //Vinqueur 3e place $this->third[] = array(array(array('name' => $gamme_third->winner()->first() ? $gamme_third->winner()->first()->name : "-", 'id' => $gamme_third->winner_id))); } }
/** * Remove the specified resource from storage. * DELETE /projectstages/{id} * * @param int $id * @return Response */ public function destroy($id) { $stage = Stage::find($id)->delete(); if (is_null($stage)) { $class = 'error'; $message = 'Record does not exist.'; } else { $class = 'success'; $message = 'Record successfully deleted.'; } return Redirect::route('project.stage.index')->with('class', $class)->with('message', $message); }