예제 #1
0
 public function register(Request $request)
 {
     $user = new User();
     $userService = new UserService();
     $uservalidator = new UserValidator();
     $response = new Response();
     $constants = new AppConstants();
     if (!$uservalidator->userRegistrationValidator($request)) {
         $response->setResponseStatus($constants->FAILURE());
         $response->setResponseMessage($constants->USER_VALIDATION_ERROR_MESSAGE());
     } else {
         $user->user_first_name = $request->user_first_name;
         $user->user_last_name = $request->user_last_name;
         $user->user_email = $request->user_email;
         $user->user_password = bcrypt($request->user_password);
         $result = $userService->createuser($user);
         if ($result == $constants->USER_INSERT_SUCCESS_STATUS()) {
             $response->setResponseStatus($constants->SUCCESS());
             $response->setResponseMessage($constants->USER_INSERT_SUCCESS_MESSAGE());
         } else {
             if ($result == $constants->USER_ALREADY_EXISTS_STATUS()) {
                 $response->setResponseStatus($constants->FAILURE());
                 $response->setResponseMessage($constants->USER_ALREADY_EXISTS_MESSAGE());
             } else {
                 $response->setResponseStatus($constants->FAILURE());
                 $response->setResponseMessage($constants->USER_INSERT_FAILURE_MESSAGE());
             }
         }
     }
     return json_encode(array("status" => $response->getResponseStatus(), "message" => $response->getResponseMessage()));
 }
 public function register(Request $request)
 {
     $user = new User();
     $userService = new UserService();
     $uservalidator = new UserValidator();
     $response = array();
     if (!$uservalidator->userRegistrationValidator($request)) {
         $response = array("status" => "failure", "message" => "Validation Error Occurs");
     } else {
         $user->first_name = $request->firstName;
         $user->last_name = $request->lastName;
         $user->email_id = $request->emailId;
         $user->password = $request->password;
         $response = $userService->createuser($user);
     }
     return $response;
 }