public function add_rule($hash_id, Request $request)
 {
     $enfermedad = Disease::findOrFail($this->decode($hash_id));
     $sintomas = Symptom::orderBy('name', 'asc')->lists('name', 'id')->toArray();
     $reglas = Rule::with('symptom')->where('disease_id', $enfermedad->id)->get()->groupBy('number');
     if ($request->isMethod('post')) {
         $this->validate($request, ['sintomas' => 'required']);
         if ($this->checkIfRuleExists($request->sintomas)) {
             alert('La regla ya existe, por favor ingrese otros síntomas', 'danger');
             return redirect()->back();
         }
         $lastRule = Rule::orderBy('id', 'desc')->first();
         if (is_null($lastRule)) {
             $numberRule = 1;
         } else {
             $numberRule = intval($lastRule->number) + 1;
         }
         $symptoms = Symptom::findOrFail($request->sintomas);
         foreach ($symptoms as $symptom) {
             $rule = new Rule();
             $rule->number = $numberRule;
             $rule->disease()->associate($enfermedad);
             $rule->symptom()->associate($symptom);
             $rule->save();
         }
         alert('Se registró la regla con éxito');
         return redirect()->back();
     }
     return view('admin.disease.add_rule')->with('enfermedad', $enfermedad)->with('reglas', $reglas)->with('sintomas', $sintomas);
 }