Esempio n. 1
0
 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), 'mode' => 1]);
         $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(), 'longitude' => '0', 'latitude' => '0']);
         $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]]);
         /* Seventh -> Create Consultation Times */
         ConsultationTimes::create(['doc_id' => $doc_ob->id, 'time_1' => '-', 'time_2' => '-', 'time_3' => '-']);
     } catch (Exception $e) {
         $this->LogError('Non Formal Doctor Create Function', $e);
     }
     $res['CHECK'] = "SUCCESS";
     /* Return Json Type Object */
     return response()->json($res);
 }