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);
 }
 public function create(Request $request)
 {
     if ($request->session()->has('session_sintomas')) {
         $request->session()->forget('session_sintomas');
     }
     $sintomas = Symptom::orderBy('name', 'asc')->lists('name', 'id')->toArray();
     return view('user.diagnostic.create')->with('sintomas', $sintomas);
 }
 public function create()
 {
     $sintomas = Symptom::orderBy('name', 'asc')->with('rules')->paginate(10);
     return view('admin.symptom.index')->with('sintomas', $sintomas);
 }
 public function index()
 {
     $sintomas = Symptom::orderBy('name', 'asc')->paginate(20);
     return view('user.symptom.index')->with('sintomas', $sintomas);
 }