public function UpdateDoctorAccount(Request $request) { //dd($request); $doc = json_decode($_COOKIE['doctor_user'], true); $doctor_id = $doc[0]['doc_id']; // Holds Doctor ID $user_id = $doc[0]['id']; // Holds User ID try { /* Update Doctor details */ $doctor_ob = Doctors::find($doctor_id); //$doctor_ob->first_name = Input::get('first_name'); //$doctor_ob->last_name = Input::get('last_name'); $doctor_ob->dob = Input::get('dob'); $doctor_ob->nic = Input::get('nic'); $doctor_ob->address_1 = Input::get('address_1'); $doctor_ob->address_2 = Input::get('address_2'); $doctor_ob->city = Input::get('city'); $doctor_ob->district = Input::get('district'); $doctor_ob->contact_number = Input::get('contact_no'); $doctor_ob->email = Input::get('email'); $doctor_ob->description = Input::get('doc_description'); $doctor_ob->longitude = Input::get('longitude'); $doctor_ob->latitude = Input::get('latitude'); $doctor_ob->save(); /* Update Specialization Details */ $specialized_ob = Specialization::whereDoc_id($doctor_id)->first(); $specialized_ob->spec_1 = Input::get('specialized')[0]; $specialized_ob->spec_2 = Input::get('specialized')[1]; $specialized_ob->spec_3 = Input::get('specialized')[2]; $specialized_ob->spec_4 = Input::get('specialized')[3]; $specialized_ob->spec_5 = Input::get('specialized')[4]; $specialized_ob->save(); /* Update Treatment Details */ $treatment_ob = Treatments::whereDoc_id($doctor_id)->first(); $treatment_ob->treat_1 = Input::get('treatments')[0]; $treatment_ob->treat_2 = Input::get('treatments')[1]; $treatment_ob->treat_3 = Input::get('treatments')[2]; $treatment_ob->treat_4 = Input::get('treatments')[3]; $treatment_ob->treat_5 = Input::get('treatments')[4]; $treatment_ob->save(); /* Update Consultation Times Details */ $consult_ob = ConsultationTimes::whereDoc_id($doctor_id)->first(); $consult_ob->time_1 = Input::get('consult_times')[0]; $consult_ob->time_2 = Input::get('consult_times')[1]; $consult_ob->time_3 = Input::get('consult_times')[2]; $consult_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_doctor_image($request, $user_id); /* Updates Database Images table Image_path with new path */ $img_ob = Images::whereUser_id($user_id)->first(); $img_ob->image_path = "profile_images/doctor_images/doc_profile_img_" . $user_id . ".png"; $img_ob->save(); } return Redirect::to('/DoctorAccount'); } catch (Exception $e) { $this->LogError('Update Doctor Account Function', $e); } }
public function add_doctor_save(Request $request) { $time_stamp = time(); try { /* First -> Create Users Record */ User::create(['name' => Input::get('first_name'), 'email' => $time_stamp, 'password' => md5($time_stamp)]); $user = User::whereEmail($time_stamp)->wherePassword(md5($time_stamp))->first(); /* Second -> Images Record */ Images::create(['user_id' => $user->id, 'image_path' => 'profile_images/default_user_icon.png']); /* Third -> Doctor Object Is Created */ Doctors::create(['user_id' => $user->id, 'doc_type' => 'NON_FORMAL', 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'gender' => Input::get('gender'), 'dob' => '-', 'nic' => '-', 'address_1' => Input::get('address_1'), 'address_2' => Input::get('address_2'), 'city' => Input::get('city'), 'district' => Input::get('district'), 'contact_number' => Input::get('contact_number'), 'email' => Input::get('email'), 'description' => Input::get('doc_description'), 'rating' => 0, 'tot_stars' => 0, 'rated_tot_users' => 0, 'reg_date' => new \DateTime()]); $doc_ob = Doctors::whereUser_id($user->id)->first(); /* Fourth -> add Non Formal Doctors */ $user_cookie = json_decode($_COOKIE['user'], true); Non_Formal_doctors::create(['doctor_id' => $doc_ob->id, 'suggested_user' => $user_cookie[0]['id']]); /* Fifth -> Create Specialization */ Specialization::create(['doc_id' => $doc_ob->id, 'spec_1' => Input::get('specialized')[0], 'spec_2' => Input::get('specialized')[1], 'spec_3' => Input::get('specialized')[2], 'spec_4' => Input::get('specialized')[3], 'spec_5' => Input::get('specialized')[4]]); /* Sixth -> Create Treatments */ Treatments::create(['doc_id' => $doc_ob->id, 'treat_1' => Input::get('treatments')[0], 'treat_2' => Input::get('treatments')[1], 'treat_3' => Input::get('treatments')[2], 'treat_4' => Input::get('treatments')[3], 'treat_5' => Input::get('treatments')[4]]); } catch (Exception $e) { $this->LogError('Non Formal Doctor Create Function', $e); } return Redirect::to('/adddoctor'); }