예제 #1
0
 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'));
 }