コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request, NewUserEmail $email)
 {
     //
     Log::info('Form posted. checking validation');
     $rules = $this->getSpecRules();
     //dd($rules);
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         # code...
         Log::error("Validation failed. Returning back.");
         return redirect()->back()->withErrors($validator);
     }
     Log::info("Validation passed.");
     Log::info("Attempting to create the doc");
     $input = $request->all();
     $userRelated = new UserRelated();
     //dd($input);
     $password = UserRelated::generatePassword();
     //dd($password);
     $user = $this->createUser($input['email'], $password);
     //dd($user);
     if (!$user) {
         # code...
         Log::error("Error while creating the user for the doc");
         $user->delete();
     }
     $profile = UserRelated::createProfile($user->id, $input['first_name'], $input['last_name'], $input['address_line1'], $input['address_line2'], $input['city'], $input['state'], $input['country'], $input['postcode'], $input['phone'], $input['passport_no']);
     //dd($profile);
     if (!$profile) {
         # code...
         Log::error("Error creating the profile for the doc");
         Log::info("will destroy both the user and the profile");
         $user->delete();
         $profile->delete();
     }
     $specialism = $this->createSpecialism($user->id, $input['qualification'], $input['specialism']);
     if (!$specialism) {
         # code...
         Log::error("Error creating the specialism for the specialism");
         Log::info("Proceeding to destroy all three things");
         $user->delete();
         $profile->delete();
         $specialism->delete();
     }
     $email->sendEmail($user->email, $password, "emails.newUserAccount");
     Log::info("Successfully created the specialism. return to the dash");
     return redirect('admin/doctor');
 }
コード例 #2
0
ファイル: NurseController.php プロジェクト: a-madhukar/Aliyah
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request, NewUserEmail $email)
 {
     //
     Log::info("Submitting the add nurse form");
     $rules = $this->getNurseValRules();
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         # code...
         Log::error("Failed validation submitting the nurse form");
         return redirect()->back()->withErrors($validator);
     }
     Log::info("Validation passed");
     $input = $request->all();
     Log::info("Creating the user");
     Log::info("generating a random password");
     $password = UserRelated::generatePassword();
     $user = $this->createUser($input['email'], $password);
     if (!$user) {
         # code...
         Log::error("Failed to create user for nurse");
         $user->delete();
         return redirect()->back()->withErrors("Failed to create user for nurse");
     }
     $profile = UserRelated::createProfile($user->id, $input['first_name'], $input['last_name'], $input['address_line1'], $input['address_line2'], $input['city'], $input['state'], $input['country'], $input['postcode'], $input['phone'], $input['passport_no']);
     if (!$profile) {
         # code...
         Log::error("Error creating the profile for the nurse");
         $user->delete();
         $profile->delete();
         return redirect()->back()->withErrors("Error creating the profile for the nurse");
     }
     $resp = $this->createResponsibility($user->id, $input['ward']);
     if (!$resp) {
         # code...
         Log::error("failed to create the responsibility");
         $user->delete();
         $profile->delete();
     }
     $email->sendEmail($user->email, $password, "emails.newUserAccount");
     Log::info("created the nurse");
     return redirect('admin/nurse');
 }
コード例 #3
0
ファイル: TestController.php プロジェクト: a-madhukar/Aliyah
 public function sendTestEmail(NewUserEmail $newUserEmail)
 {
     $newUserEmail->sendEmail("*****@*****.**", "thisWorks123", "emails.newUserAccount");
     return "done";
 }