public function postUpdateParticipant(Request $request) { if ($request->ajax()) { $input = $request->only(['user_id', 'state']); $input['course_id'] = Auth::user()->course->id; Participant::where('course_id', '=', $input['course_id'])->where('user_id', '=', $input['user_id'])->update($input); return response()->json(['id' => $input['user_id'], 'value' => $input['state'] == Participant::REJECTED ? 'Odmietnutý' : 'Prihlásený']); } }
/** * Crée les entrées de la table Participants correspondant aux équipes */ public function run() { //TODO: à refaire car ca plante si on seed 2 fois car les id de région et de sports sont hardcodés $entrees = [["Arthur", "Archambault", 1, 1, 1, 0], ["Beowulf", "Beaulieu", 2, 1, 2, 0], ["Circé", "Charron", 3, 1, 3, 1], ["Donatello", "DeGrandPré", 4, 2, 1, 0], ["Elsa", "Eiffel", 5, 2, 2, 1], ["Francesco", "Funiculaire", 6, 2, 3, 0], ["Ginette", "Gargantua", 7, 3, 1, 1], ["Henri", "Hippocampe", 8, 3, 2, 0], ["Ivan", "Impitoyable", 9, 3, 3, 0], ["Josephte", "Jamboni", 10, 4, 1, 1], ["Kitty", "KitKat", 11, 4, 2, 1], ["Lola", "Lilalou", 12, 4, 3, 1], ["Manon", "Moriarty", 13, 5, 1, 1], ["Norbert", "Nucléaire", 14, 5, 2, 0], ["Osiris", "Orangeraie", 15, 5, 3, 0], ["Patricia", "Pédoncule", 16, 6, 1, 1], ["Quetzal", "Quelconque", 17, 6, 2, 0], ["Rosa", "Rubéole", 18, 6, 3, 1], ["Stephen", "Satan", 19, 1, 1, 0], ["Tarantula", "Tantrique", 20, 2, 2, 1], ["Ursulin", "Ultime Ninja", 21, 3, 3, 0], ["Vanessa", "Velociraptor", 22, 4, 1, 1], ["Waldorf", "Wolfenstein", 23, 5, 2, 0], ["Xanetia", "Xylophage", 24, 6, 3, 1], ["Yannick", "Ytterbium", 25, 1, 4, 0], ["Zaza", "Zébulon", 26, 2, 4, 1]]; $sports = Sport::all(); $regions = Region::all(); Participant::where('equipe', '=', 0)->delete(); foreach ($entrees as $entree) { $participant = new Participant(); $participant->prenom = $entree[0]; $participant->nom = $entree[1]; $participant->numero = $entree[2]; $participant->region_id = $regions[$entree[3]]->id; $participant->sexe = $entree[5]; $participant->naissance = new DateTime(); $participant->equipe = false; $participant->save(); $participant->sports()->attach([$sports[$entree[4]]->id]); } }
public function getNewNotifications() { $threadsWithNewMessages = []; $participants = Participant::where('user_id', $this->id)->lists('last_read', 'thread_id'); /** * @todo: see if we can fix this more in the future. * Illuminate\Foundation is not available through composer, only in laravel/framework which * I don't want to include as a dependency for this package...it's overkill. So let's * exclude this check in the testing environment. */ if (getenv('APP_ENV') == 'testing' || !str_contains(\Illuminate\Foundation\Application::VERSION, '5.0')) { $participants = $participants->all(); } if ($participants) { $threads = Thread::whereIn('id', array_keys($participants))->get(); foreach ($threads as $thread) { if ($thread->updated_at > $participants[$thread->id] && $thread->getLatestMessageAttribute()->type == 'notification') { $threadsWithNewMessages[] = $thread->id; } } } return $threadsWithNewMessages; }
/** * Find a user by barcode * * @param $barcode * @return array */ public function findByBarcode($barcode) { $participant = Participant::where('barcode', $barcode)->first(); return ['id' => $participant->id, 'name' => $participant->name, 'image' => $participant->image, 'crew' => $participant->crew]; }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $equipe = Equipe::findOrFail($id); $membres = $equipe->idMembres(); // Les participants susceptibles d'être ajoutés à l'équipe, triés par nom // On ne peut pas changer la région d'une équipe car ca aurait des impacts sur les membres de l'équipe $joueurs = Participant::where('equipe', '=', '0')->orderBy('nom')->orderBy('prenom')->where('region_id', '=', $equipe->region_id)->join('participant_sport', 'participants.id', '=', 'participant_sport.participant_id')->where('sport_id', '=', $equipe->sport()->id)->get(); // Redirection vers la page d'édition pour permettre d'ajouter des membres return View::make('equipes.edit', compact('equipe', 'joueurs', 'membres')); }
/** * 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')); }