Пример #1
0
 public function featuredDoctorUpdate(Request $request)
 {
     $count = Input::get("count");
     //featured doctor id
     $doc_id = Input::get("doc_id");
     //doctor id
     try {
         //adding a new featured doctor field with a doctor
         if ($count == "new") {
             Featured_doc::create(['did' => $doc_id]);
         } else {
             //upadate the featured doctor table reacord with a new doctor id
             DB::table('featured_doc')->where('fid', $count)->update(['did' => $doc_id]);
         }
         //get all the feateured doctors
         $featured_doc = DB::table('featured_doc')->join('doctors', 'featured_doc.did', '=', 'doctors.id')->orderBy('fid', 'asc')->get();
         //Get all the specialization types in the specializations 5 columns
         $filter_spec = DB::select('SELECT spec_1 FROM
     (
         SELECT spec_1 AS spec_1 FROM specialization where spec_1 != ""
         UNION
         SELECT spec_2 AS spec_1 FROM specialization where spec_2 != ""
         UNION
         SELECT spec_3 AS spec_1 FROM specialization where spec_3 != ""
         UNION
         SELECT spec_4 AS spec_1 FROM specialization where spec_4 != ""
         UNION
         SELECT spec_5 AS spec_1 FROM specialization where spec_5 != ""
     ) tt WHERE spec_1 IS NOT NULL');
         //$filter_treat= DB::table('treatments')->select('treat_1')->groupBy('treat_1')->get();
         $filter_treat = DB::select('SELECT treat_1 FROM
     (
         SELECT treat_1 AS treat_1 FROM treatments where treat_1 != ""
         UNION
         SELECT treat_2 AS treat_1 FROM treatments where treat_2 != ""
         UNION
         SELECT treat_3 AS treat_1 FROM treatments where treat_3 != ""
         UNION
         SELECT treat_4 AS treat_1 FROM treatments where treat_4 != ""
         UNION
         SELECT treat_5 AS treat_1 FROM treatments where treat_5 != ""
     ) tt WHERE treat_1 IS NOT NULL');
         //selct all the doctors not in featured doctor table
         $reg_doc = DB::select(DB::raw('SELECT * FROM doctors WHERE id NOT IN (SELECT did FROM featured_doc)'));
         //pass db results to the home12 page
         $HTMLView = (string) view('costomize_home_views.home12')->with(['featured_doc1' => $featured_doc, 'reg_doctor' => $reg_doc, 'filter_spec' => $filter_spec, 'filter_treat' => $filter_treat]);
         $res['com_data'] = $HTMLView;
         return response()->json($res);
     } catch (Exception $e) {
         $HTMLView = (string) view('errors.adminError');
         $res['com_data'] = $HTMLView;
         return response()->json($res);
     }
 }