Esempio n. 1
0
 public function search(Request $request)
 {
     $data = array();
     $data['days'] = \App\Day::lists('name', 'id');
     $data['article'] = ArticleCategory::with('articles')->get();
     $data['city'] = \App\City::all();
     $data['specialization'] = \App\Specialization::all();
     $data['city_k'] = urldecode($request->input('city'));
     $data['specialization_k'] = urldecode($request->input('specialization'));
     $data['keyword'] = urldecode($request->input('keyword'));
     $data['gender_k'] = $request->input('gender');
     $data['practice_day_k'] = $request->input('practice_day');
     $data['city_obj'] = \App\City::where('name', 'like', '%' . $data['city_k'] . '%')->lists('id');
     $arr_specialization = \App\Specialization::where('name', 'like', '%' . $data['specialization_k'] . '%')->lists('id');
     /*$result = \App\Specialization::where('name','like','%'.$data['specialization_k'].'%')
       ->whereHas('doctors', function($query) use($data){
           $query->whereIn('city_id', $data['city_obj'])
               ->where('name','like', '%'.$data['keyword'].'%')
               ->whereHas('day', function($query) use($data){
                 if(!empty($data['practice_day_k']) > 0)
                   $query->whereIn('days.id', $data['practice_day_k']);
               })
           ;
           if(!empty($data['gender_k'])){
             $query->where('gender',$data['gender_k']);
           }
       })->
       with('doctors')->get();*/
     $result = \App\Doctor::whereIn('city_id', $data['city_obj'])->where('name', 'like', '%' . $data['keyword'] . '%')->whereHas('day', function ($query) use($data) {
         if (!empty($data['practice_day_k']) > 0) {
             $query->whereIn('days.id', $data['practice_day_k']);
         }
     });
     if (!empty($data['gender_k'])) {
         $result->where('gender', $data['gender_k']);
     }
     $result = $result->paginate(10);
     $data['article'] = ArticleCategory::with('articles')->get();
     $data['content'] = $result;
     return view('frontend.pages.home.search-result', compact('data'));
 }
Esempio n. 2
0
 public function register()
 {
     //
     $data = array();
     $data['content'] = null;
     $data['list_gender'][0] = 'L';
     $data['list_gender'][1] = 'P';
     $data['city'] = \App\City::all();
     $data['specialization'] = \App\Specialization::all();
     $data['article'] = \App\ArticleCategory::with('articles')->get();
     return view('frontend.pages.clinic.register')->with('data', $data);
 }
Esempio n. 3
0
 public function getDoctorsInfoList(Request $request)
 {
     if (Auth::check()) {
         /*
          * Добавление врача в БД
          */
         if ($request->has("add_doctor")) {
             $newDoc = new Doctor();
             $newDoc->name = $request->input("new_doctor_name");
             $newDoc->spec_id = $request->input("new_spec_id");
             $newDoc->save();
         }
         /*
          * Удаление врача из БД
          */
         if ($request->has("del_doctor")) {
             $delDoc = Doctor::find($request->input("del_doctor_id"));
             $delDoc->delete();
         }
         /*
          * Добавление специализации в БД
          */
         if ($request->has("add_spec")) {
             $newSpec = new Specialization();
             $newSpec->name = $request->input("new_spec_name");
             //echo "true";
             //exit;
             $newSpec->save();
         }
         /*
          * Удаление специализации из БД
          */
         if ($request->has("del_spec")) {
             /*echo "id";
               echo $request->input("spec_list");
               exit;*/
             $delSpec = Specialization::find($request->input("spec_list"));
             $delSpec->delete();
         }
         //$doctors = Doctor::paginate(15);
         $doctors = Doctor::paginate(15);
         $spec = Specialization::all();
         $user = Auth::user();
         $data["user_id"] = $user->id;
         $data["user_fullname"] = $user->fullname;
         /* foreach ($doctors as $doc){
                print_r($doc->spec);
            }*/
         //print_r($doctors);
         //exit;
         return view("doctors-list", ["doctors" => $doctors, "spec" => $spec, "data" => $data]);
     }
 }