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 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); }
public function blockUser(Request $request, $user_id) { $reason = Input::get('reason'); try { //block the user User::where('id', $user_id)->update(['mode' => 0]); Patients::where('user_id', $user_id)->update(['comments' => $reason]); $user = Patients::whereUser_id($user_id)->first(); /* Send an Email */ self::sendBolckedEmail($user->first_name, $user->last_name, $user->email); $HTMLView = (string) view('admin_patients_views.home_1'); $res['error'] = false; $res['page'] = $HTMLView; return response()->json($res); } catch (Exception $e) { $res['error'] = true; $HTMLView = (string) view('errors.adminError'); $res['page'] = $HTMLView; return response()->json($res); } }