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 filterDoctors(Request $request, $rate, $spec, $treat) { try { //Get all the featured doctors $fdoc = Featured_doc::all(); $count = 0; //put the previously got featured doctors to array foreach ($fdoc as $p) { $aa[$count] = $p->did; $count++; } //get the doctors according to the specifications and doctors who are not in featured doctors table $result = DB::table('doctors')->join('treatments', 'doctors.id', '=', 'treatments.doc_id')->join('specialization', 'doctors.id', '=', 'specialization.doc_id')->whereNotIn('doctors.id', $aa); if ($rate != "all") { $result->where('rating', '=', $rate); } if ($spec != "all") { $result->where('spec_1', '=', $spec)->orWhere('spec_2', '=', $spec)->orWhere('spec_3', '=', $spec)->orWhere('spec_4', '=', $spec)->orWhere('spec_5', '=', $spec); } if ($treat != "all") { $result->where('treat_1', '=', $treat)->orWhere('treat_2', '=', $treat)->orWhere('treat_3', '=', $treat)->orWhere('treat_4', '=', $treat)->orWhere('treat_5', '=', $treat); } $reg_doc = $result->get(); $res['page'] = $reg_doc; $res['error'] = false; return response()->json($res); } catch (Exception $e) { $HTMLView = (string) view('errors.adminError'); $res['page'] = $HTMLView; $res['error'] = true; return response()->json($res); } }