/** * Affiche le formulaire pour éditer la ressource. * * @param int $id l'id du rôle à éditer * @return Response */ public function edit($id) { try { $delegue = Delegue::findOrFail($id); $regions = Region::all(); $roles = Role::all(); $postes = $delegue->idRoles(); // Si de vieilles entrées n'ont pas de date de naissance, on utilise les valeurs par défaut $anneeDefaut = date('Y') - 20; $moisDefaut = 0; $jourDefaut = 0; if ($delegue->date_naissance) { // Déterminer les valeurs des trois comboboxes pour la date de naissance. $stringsDate = explode('-', $delegue->date_naissance); $anneeDefaut = $stringsDate[0] + 1; $moisDefaut = $stringsDate[1] + 1; $jourDefaut = $stringsDate[2] + 1; } // Générer les listes des comboboxes pour la date de naissance. $listeAnnees = ParticipantsController::generer_liste(date('Y') - 100, 101); $listeMois = ParticipantsController::generer_liste(1, 12); $listeJours = ParticipantsController::generer_liste(1, 31); return View::make('delegues.edit', compact('delegue', 'regions', 'roles', 'postes', 'listeAnnees', 'anneeDefaut', 'listeMois', 'listeJours', 'anneeDefaut', 'moisDefaut', 'jourDefaut')); } catch (Exception $e) { App: abort(404); } }
/** * Recherche une entrée de la bd. * * @return Response */ public function recherche() { //TODO: mettre cette logique dans index() $routeActionName = 'ParticipantsController@index'; $listeRecherches = ParticipantsController::getListeRecherches(); $listeFiltres = ParticipantsController::getListeFiltres(); $infosTri = ParticipantsController::getInfosTri(); $input = Input::all(); $valeurFiltre = $input['listeFiltres']; $valeurRecherche = $input['entreeRecherche']; if ($valeurRecherche != '') { if ($valeurFiltre == 0) { $participants = Participant::where('nom', 'like', $valeurRecherche . '%')->get(); } elseif ($valeurFiltre == 1) { $participants = Participant::where('prenom', 'like', $valeurRecherche . '%')->get(); } elseif ($valeurFiltre == 2) { if (is_numeric($valeurRecherche)) { $participants = Participant::where('numero', $valeurRecherche)->get(); } else { $participants = new \Illuminate\Database\Eloquent\Collection(); } } elseif ($valeurFiltre == 3) { $region = Region::where('nom_court', '=', $valeurRecherche)->first(); if ($region) { $participants = $region->participants()->get(); } else { $participants = new \Illuminate\Database\Eloquent\Collection(); } } else { $participants = Participant::all(); } } else { $participants = Participant::all(); } $participants = ParticipantsController::trierColonnes($participants); return View::make('participants.index', compact('participants', 'routeActionName', 'infosTri', 'listeFiltres', 'listeRecherches', 'valeurFiltre', 'valeurRecherche')); }