/** * @param string $backUrl * @param int $player_id * @return \Illuminate\Http\RedirectResponse */ public function add($backUrl = 'entree', $player_id = 0) { if ($player_id == 0) { return Redirect::route($backUrl); } $player = Player::find($player_id); // Cree Entree $entree = new Entree(); $entree->compet_id = MySession::getModel('compet')->id; $entree->statusentree_id = 1; $entree->teamname = ""; $entree->hcp = 0; $entree->save(); // Cree les EntreePlayers (en fonction du Compet->TypeCompet->nbplayers $nbPlayers = MySession::getModel('compet')->typecompet->nbplayers; for ($pl = 1; $pl <= $nbPlayers; $pl++) { $entreePlayer = new Entreeplayer(); $entreePlayer->entree_id = $entree->id; if ($pl == 1) { $entreePlayer->player_id = $player->id; $entreePlayer->hcp = $player->hcp; } $entreePlayer->num = $pl; $entreePlayer->save(); // get Categorie if ($pl == 1) { $entreePlayer->competcategorie_id = $entreePlayer->getCategorie(); $entreePlayer->save(); } } return Redirect::route($backUrl); }
public function skipDoDelete($backUrl = 'entree', $id) { $entreePlayer = Entreeplayer::find($id); $entreePlayer->player_id = 0; $entreePlayer->hcp = 0; $entreePlayer->competcategorie_id = 0; $entreePlayer->save(); return Redirect::route($backUrl); }
public function getListPlayerId() { // Liste des Joueurs deja inscrit dans ces EntreePlayer (donc la compétition en cours) return Entreeplayer::whereEntreeId($this->id)->lists('player_id'); }