public function GetCommentsOnDoctor()
 {
     $doc = json_decode($_COOKIE['doctor_user'], true);
     $doc_id = $doc[0]['doc_id'];
     // this should be replaced by $COOKIE reference
     try {
         $comments = Comments::whereDoctor_id($doc_id)->orderBy('id', 'DESC')->limit(20)->get();
         foreach ($comments as $com) {
             $pat = Patients::whereUser_id($com->user_id)->first();
             $img = Images::whereUser_id($pat->user_id)->first();
             $main_ob['com_data'] = $com;
             $main_ob['pat_first_name'] = $pat->first_name;
             $main_ob['pat_last_name'] = $pat->last_name;
             $main_ob['pat_img'] = $img->image_path;
             $res[] = $main_ob;
         }
     } catch (Exception $e) {
         $this->LogError('AjaxController Get Comments On Doctor Function', $e);
     }
     return response()->json($res);
 }
示例#2
0
 public function update_account(Request $request)
 {
     //dd($request);
     if (isset($_COOKIE['user'])) {
         $user = json_decode($_COOKIE['user'], true);
         try {
             $user_ob = User::find($user[0]['id']);
             $user_ob->email = Input::get('username');
             $user_ob->save();
             $patient_ob = Patients::whereUser_id($user[0]['id'])->first();
             //$patient_ob->first_name = Input::get('first_name');
             //$patient_ob->last_name = Input::get('last_name');
             $patient_ob->contact_number = Input::get('contact_no');
             $patient_ob->email = Input::get('email');
             $patient_ob->save();
             /* Check Whether New Image Upload is Available or not */
             if (isset(Input::file('profile_img')[0])) {
                 /* This function will upload image */
                 self::upload_image($request, $user[0]['id']);
                 /* Updates Database Images table Image_path with new path */
                 $img_ob = Images::whereUser_id($user[0]['id'])->first();
                 $img_ob->image_path = "profile_images/user_images/user_profile_img_" . $user[0]['id'] . ".png";
                 $img_ob->save();
             }
             /* Updates Cookie Details */
             //$user_cookie = array(['id' => $user[0]['id'], 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')]);
             //setcookie('user', json_encode($user_cookie), time() + 3600); // Cookie is set for 1 hour
         } catch (Exception $e) {
             $this->LogError('Update User Account', $e);
         }
         return Redirect::to('/myaccount/' . $user[0]['first_name']);
     } else {
         return Redirect::to('/');
     }
 }
 public function graph1Count()
 {
     try {
         //get the count af users accordig to registered dates
         $graph1 = DB::select(DB::raw('SELECT DATE(reg_date) AS y,COUNT(*) AS item1 FROM patients GROUP BY DATE(reg_date)'));
         //get the count af doctors accordig to registered dates
         $graph2 = DB::select(DB::raw('SELECT DATE(reg_date) AS y,COUNT(*) AS item1 FROM doctors GROUP BY DATE(reg_date)'));
         //get the count af doctors accordig to registered dates and doctor types
         $graph3 = DB::select(DB::raw('SELECT DATE(reg_date) AS y ,SUM(CASE WHEN doc_type = "FORMAL" THEN 1 ELSE 0 END) AS item1, SUM(CASE WHEN doc_type = "NON_FORMAL" THEN 1 ELSE 0 END) AS item2    FROM doctors  GROUP BY DATE(reg_date)'));
         //get all user count
         $Patients = Patients::all();
         //Get formal doctor count
         $Formal_doctors = Formal_doctors::all();
         //Get non formal doctor count
         $Non_Formal_doctors = Non_Formal_doctors::all();
         //get the number of results in each quary result
         $graph41 = sizeof($Patients);
         $graph42 = sizeof($Formal_doctors);
         $graph43 = sizeof($Non_Formal_doctors);
         //pass the values through json
         $res['graph_1'] = $graph1;
         $res['graph_2'] = $graph2;
         $res['graph_3'] = $graph3;
         $res['graph_41'] = $graph41;
         $res['graph_42'] = $graph42;
         $res['graph_43'] = $graph43;
     } catch (Exception $e) {
         $this->LogError('AdminController Register_Page Function', $e);
     }
     return response()->json($res);
 }
 public function user_remove(Request $request, $user_id)
 {
     Patients::where('id', $user_id)->delete();
     $patients = Patients::orderBy('first_name', 'desc')->get();
     $patients1 = Patients::orderBy('reg_date', 'desc')->get();
     $HTMLView = (string) view('admin_patients_views.home_1')->with(['comment' => $patients, 'comment1' => $patients1]);
     $res['page'] = $HTMLView;
     return response()->json($res);
 }
 public function forgotten_password_email(Request $request)
 {
     try {
         /* Get Patients table First Name and Last Name Field */
         $patient = Patients::whereEmail(Input::get('reset_ps_email'))->first();
         /* Generate Random Key in Upper Case Letters with 6 characters */
         $acc_code = strtoupper(substr(md5(rand()), 0, 6));
         $subject['sub'] = "Reset Password at eAyurveda.lk";
         $subject['email'] = Input::get('reset_ps_email');
         $subject['name'] = $patient->first_name . ' ' . $patient->last_name;
         Mail::send('emails.password_reset_mail', ['access_code' => $acc_code], function ($message) use($subject) {
             $message->to($subject['email'], $subject['name'])->subject($subject['sub']);
         });
         $data['CHECK'] = "YES";
         $data['EMAIL'] = Input::get('reset_ps_email');
         $data['ACCESS_KEY'] = $acc_code;
     } catch (Exception $e) {
         $this->LogError('AjaxController Forgotten Password Email Function', $e);
     }
     return response()->json($data);
 }