public function store(Request $request) { $competitor = new Competitor($request->all()); $competitor->save(); Flash::success('Competitor ' . $competitor->name . ' se ha registrado correctamente'); return view('register.competitor.create'); }
/** * Run the database seeds. * * @return void */ public function run() { $competitor = new Competitor(); $competitor->picture_url = "/img/competition/test-duvel.jpg"; $competitor->ip = "192.168.56.100"; $competitor->user_id = 1; $competitor->save(); }
/** * Execute the console command. * * @return mixed */ public function handle() { // \Log::info('I was here @' . Carbon::now() ); $thisDate = Date::where('endDate', '<', Carbon::now())->orderby('endDate', 'DESC')->first(); $competitors = Competitor::where('created_at', '>', $thisDate->startDate)->where('created_at', '<', $thisDate->endDate)->where('is_deleted', '=', false)->get(); if (!count($thisDate->winner) && count($competitors)) { // var_dump($competitors); $winner = $competitors->first(); foreach ($competitors as $competitor) { var_dump($competitor->getTotalVotes()); echo '</br>'; if ($competitor->getTotalVotes() > $winner->getTotalVotes()) { $winner = $competitor; } } $newWinner = new Winner(); $newWinner->competitor_id = $winner->id; $newWinner->date_id = $thisDate->id; $newWinner->save(); } }
public function deleteCompetitor($id) { $competitor = Competitor::findOrFail($id); $competitor->is_deleted = abs($competitor->is_deleted - 1); $competitor->save(); return redirect()->back(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy(Competitor $competitor) { $competitor->delete(); return redirect("competitors"); }
public function exportAll() { $table = Competitor::all(); $user = User::first(); $makeKeys = $table; $output = ""; $keyArray = []; foreach ($makeKeys->first()->toArray() as $key => $value) { // var_dump( $key ); array_push($keyArray, $key); } // var_dump($table->first()->user->toArray()); foreach ($user->toArray() as $key => $value) { if ($key !== 'id') { array_push($keyArray, $key); } } // var_dump($table . '</br>'); // var_dump($makeKeys); // var_dump( $keyArray ); $output .= implode(",", $keyArray) . "\n"; foreach ($table as $row) { // var_dump($row);echo'</br>'; $output .= implode(",", $row->toArray()); $output .= implode(",", $row->user->toArray()) . "\n"; } // echo $output; $headers = array('Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment; filename="ExportFileName.csv"'); return Response::make(rtrim($output, "\n"), 200, $headers); }
public function destroy($id) { Competitor::findOrFail($id)->delete(); return redirect('/admin/competitors')->with('status', 'Versenyző törölve'); }
public function competitor_statistics(Request $request) { $competitors = Competitor::all(); //Nevezett versenyzők $competitor_in = []; foreach ($competitors as $comp) { $competitor_in[$comp->id] = $comp->full_name_birthday; } natsort($competitor_in); reset($competitor_in); $act_competitor = key($competitor_in); //Kiválasztott versenyző if ($request->competitor) { $act_competitor = $request->competitor; } $all_result = Result::where('competitor_id', '=', $act_competitor)->orderBy('total_points', 'desc')->get(); //Úszás és kombinált távok mentése $swim_200 = ['Ifi B', 'Ifi A', 'Junior', 'Felnőtt', 'Senior']; $swim_100 = ['Ifi C', 'Ifi D']; $swim_50 = ['Ifi E', 'Ifi F']; $ce_3200 = ['Ifi A', 'Junior', 'Felnőtt', 'Senior']; $ce_2400 = ['Ifi B']; $ce_1600 = ['Ifi C']; $ce_800 = ['Ifi D']; $ce_400 = ['Ifi E', 'Ifi F']; //Lovaglás legjobb $best_riding = Result::where('competitor_id', '=', $act_competitor)->where('riding_points', '!=', 0)->orderBy('riding_points', 'desc')->first(); //Vívás legjobb $best_fencing = Result::where('competitor_id', '=', $act_competitor)->where('fencing_points', '!=', 0)->orderBy('fencing_points', 'desc')->first(); //Totál legjobb $best_total = Result::where('competitor_id', '=', $act_competitor)->where('total_points', '!=', 0)->orderBy('total_points', 'desc')->first(); //Úszás legjobbak $best_swimming_200 = Result::whereIn('age_group', $swim_200)->where('competitor_id', '=', $act_competitor)->where('swimming_time', '!=', '')->orderBy('swimming_time', 'asc')->first(); $best_swimming_100 = Result::whereIn('age_group', $swim_100)->where('competitor_id', '=', $act_competitor)->where('swimming_time', '!=', '')->orderBy('swimming_time', 'asc')->first(); $best_swimming_50 = Result::whereIn('age_group', $swim_50)->where('competitor_id', '=', $act_competitor)->where('swimming_time', '!=', '')->orderBy('swimming_time', 'asc')->first(); //Kombinált legjobbak $best_ce_3200 = Result::whereIn('age_group', $ce_3200)->where('competitor_id', '=', $act_competitor)->where('ce_time', '!=', '')->orderBy('ce_time', 'asc')->first(); $best_ce_2400 = Result::whereIn('age_group', $ce_2400)->where('competitor_id', '=', $act_competitor)->where('ce_time', '!=', '')->orderBy('ce_time', 'asc')->first(); $best_ce_1600 = Result::whereIn('age_group', $ce_1600)->where('competitor_id', '=', $act_competitor)->where('ce_time', '!=', '')->orderBy('ce_time', 'asc')->first(); $best_ce_800 = Result::whereIn('age_group', $ce_800)->where('competitor_id', '=', $act_competitor)->where('ce_time', '!=', '')->orderBy('ce_time', 'asc')->first(); $best_ce_400 = Result::whereIn('age_group', $ce_400)->where('competitor_id', '=', $act_competitor)->where('ce_time', '!=', '')->orderBy('ce_time', 'asc')->first(); return view('competitor_statistics', compact('all_result', 'competitors', 'competitor_in', 'act_competitor', 'best_riding', 'best_fencing', 'best_total', 'best_swimming_200', 'best_swimming_100', 'best_swimming_50', 'best_ce_3200', 'best_ce_2400', 'best_ce_1600', 'best_ce_800', 'best_ce_400')); }
public function teams_entry($id) { $competitiongroup = Competitiongroup::whereId($id)->firstOrFail(); //Versenyzők a listába $result_list = Result::where('competitiongroup_id', '=', $id)->get()->lists('competitor_id', 'competitor_id'); $already_in1 = Results_team::select('competitor1_id')->where('competitiongroup_id', '=', $id)->get()->lists('competitor1_id', 'competitor1_id'); $already_in2 = Results_team::select('competitor2_id')->where('competitiongroup_id', '=', $id)->get()->lists('competitor2_id', 'competitor2_id'); $already_in3 = Results_team::select('competitor3_id')->where('competitiongroup_id', '=', $id)->get()->lists('competitor3_id', 'competitor3_id'); foreach ($already_in1 as $remove) { $result_list->forget($remove); } foreach ($already_in2 as $remove) { $result_list->forget($remove); } foreach ($already_in3 as $remove) { $result_list->forget($remove); } $competitors = []; foreach ($result_list as $comp) { $temp_comp = Competitor::whereId($comp)->first(); $competitors[$comp] = $temp_comp->full_name_birthday; } natsort($competitors); //Benevezett versenyzők $competitor_list = Result::select('results.*')->where('competitiongroup_id', '=', $id)->join('competitors', 'results.competitor_id', '=', 'competitors.id')->orderBy('full_name', 'asc')->get(); $competitor_in = []; foreach ($competitor_list as $comp) { $competitor_in[$comp->id] = $comp->competitor->full_name; } natsort($competitor_in); $comp_count = count($competitor_in); //Benevezett csapatok $team_list = Results_team::where('competitiongroup_id', '=', $id)->orderBy('name')->get(); $team_in = []; foreach ($team_list as $team) { $team_in[$team->id] = $team->name; } natsort($team_in); $team_count = count($team_in); return view('backend.competitiongroups.teams_entry', compact('competitiongroup', 'competitors', 'team_in', 'team_list', 'team_count', 'competitor_in', 'competitor_list', 'comp_count')); }