예제 #1
0
 /**
  * Handle the registration of user.
  * 
  * @param type UserRegisterRequest $request 
  * @return type view
  */
 public function postRegister(UserRegisterRequest $request, UserRepository $user_gestion)
 {
     if ($request->user_type == 1) {
         if (is_null($request->siren)) {
             $errors = new MessageBag(['siren' => [trans('validation.required', ['attribute' => trans('form.siren')])]]);
             return Redirect::back()->withErrors($errors)->withInput(Input::except('siren'));
         }
         if (is_null($request->company_name)) {
             $errors = new MessageBag(['company_name' => [trans('validation.required', ['attribute' => trans('form.company_name')])]]);
             return Redirect::back()->withErrors($errors)->withInput(Input::except('company_name'));
         }
     }
     $user_id = $user_gestion->store($request);
     if ($request->user_type == 1) {
         $company_gestion = new CompanyRepository(new Company());
         $company_gestion->store($request, $user_id);
     }
     return Redirect::route('auth.register.success')->with('data_user', ['email' => $request->email, 'first_name' => $request->first_name, 'last_name' => $request->last_name]);
 }