public function get_top_rated_docs() { try { $top_rated = Doctors::orderBy('rating', 'DESC')->limit(4)->get(); foreach ($top_rated as $doc) { $temp['doc_id'] = $doc->id; $temp['doc_first_name'] = $doc->first_name; $temp['doc_last_name'] = $doc->last_name; $temp['doc_address_2'] = $doc->address_2; $temp['doc_city'] = $doc->city; $temp['doc_rating'] = $doc->rating; $img = Images::whereUser_id($doc->user_id)->first(); $temp['image_path'] = $img->image_path; $rating_main[] = $temp; } } catch (Exception $e) { $this->LogError('Get Top Rated Doctors Function', $e); } return $rating_main; }