public function total_fencing_points($id)
 {
     $competitiongroup = Competitiongroup::whereId($id)->firstOrFail();
     $competitor_list = Result::where('competitiongroup_id', '=', $id)->where('fencing_status', '')->where('dsq_status', 0)->get();
     $fencing_rule = Fencing_rule::where('bouts', '=', $competitiongroup->fencing_bouts)->firstOrFail();
     $fencing_250 = $fencing_rule->bouts_250;
     $fencing_victory_points = $fencing_rule->victory_points;
     foreach ($competitor_list as $comp) {
         $fencing_results1 = Fencing_result::where('competitiongroup_id', '=', $id)->where('competitor1_id', '=', $comp->competitor->id)->get();
         $fencing_results2 = Fencing_result::where('competitiongroup_id', '=', $id)->where('competitor2_id', '=', $comp->competitor->id)->get();
         $temp_win = 0;
         $temp_lose = 0;
         foreach ($fencing_results1 as $fence) {
             if ($fence->competitor1_id == $comp->competitor->id) {
                 $temp_win += $fence->competitor1_bouts;
                 $temp_lose += $fence->competitor2_bouts;
             }
         }
         foreach ($fencing_results2 as $fence) {
             if ($fence->competitor2_id == $comp->competitor_id) {
                 $temp_win += $fence->competitor2_bouts;
                 $temp_lose += $fence->competitor1_bouts;
             }
         }
         if ($temp_win == 0 && $temp_lose == 0) {
             $comp->fencing_win = null;
             $comp->fencing_lose = null;
         } else {
             $comp->fencing_win = $temp_win;
             $comp->fencing_lose = $temp_lose;
         }
         if ($temp_win == 0) {
             $comp->fencing_points = 0 - $comp->penalty_points_fencing;
         } else {
             $comp->fencing_points = 250 + ($comp->fencing_win - $fencing_250) * $fencing_victory_points - $comp->penalty_points_fencing;
         }
         $comp->save();
     }
     //Vívás sorrend kialakítása
     $this->fencing_order($id);
 }
 public function update(FencingRulesFormRequest $request, $id)
 {
     $fencing_rule = Fencing_rule::findOrFail($id);
     $fencing_rule->update($request->all());
     return redirect('/admin/fencing_rules')->with('status', 'Pontozás módosítva');
 }