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 removeComment(Request $request, $user_id) { try { //get the comment details for given id $user = DB::table('comments')->where('id', $user_id)->first(); $doctor_id = $user->doctor_id; //get the doctor id $rating = $user->rating; //gat the rating //take the doctor id and reduce rating $doc = Doctors::whereId($doctor_id)->first(); $rateCount = $doc->tot_stars; //get total stars rated $rateCount = (int) $rateCount - (int) $rating; // substract the deleting rating $rateUserCount = $doc->rated_tot_users; // Get total no of ratings $rateUserCount = (int) $rateUserCount - 1; $doc->tot_stars = $rateCount; $doc->rated_tot_users = $rateUserCount; $doc->save(); $uid = $user->user_id; //get the user id $user1 = DB::table('patients')->where('user_id', $uid)->first(); //get user details for the given user id $count = $user1->spam_count; //get the spam massage count $count = $count + 1; //spam count column increase by 1 DB::table('patients')->where('user_id', $uid)->update(['spam_count' => $count]); //add new spam count to the user if ($count >= 5) { //check whether spam count is exeed the given limet DB::table('users')->where('id', $uid)->update(['mode' => 0]); //block the user // 0=block //1=unblock } //remove the comment DB::table('comments')->where('id', $user_id)->delete(); $HTMLView = (string) view('admin_patients_views.home_2'); $res['page'] = $HTMLView; $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); } }