public function get_featured_docs() { try { $featured = Featured_doc::all(); foreach ($featured as $f_doc) { $doc_details = Doctors::whereId($f_doc->did)->first(); $temp['doc_id'] = $doc_details->id; $temp['doc_first_name'] = $doc_details->first_name; $temp['doc_last_name'] = $doc_details->last_name; $temp['doc_address_2'] = $doc_details->address_2; $temp['doc_city'] = $doc_details->city; $img = Images::whereUser_id($doc_details->user_id)->first(); $temp['image_path'] = $img->image_path; $featured_main[] = $temp; } } catch (Exception $e) { $this->LogError('Get Featured Doctors Function', $e); } return $featured_main; }
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); } }