/**
  * Store a newly created resource in storage.
  *
  * @param CreateUserRequest $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(CreateUserRequest $request)
 {
     $user = new User();
     $user->fill($request->all());
     $user->save();
     $message = trans('UserManagement::messages.users.store');
     if ($request->ajax()) {
         return $message;
     }
     //\Flash::success($message);
     return redirect()->route('admin.users.index');
 }
Esempio n. 2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  App\Http\Requests\CreateUserRequest
  * @param  \App\Event
  * @return \Illuminate\Http\Response
  */
 public function update(CreateUserRequest $request, User $user)
 {
     if ($request->ajax()) {
         $username = $request->input('username');
         $email = $request->input('email');
         $password = $request->input('password', '');
         $firstname = $request->input('firstname');
         $lastname = $request->input('lastname');
         $image1 = $request->input('image1');
         $image2 = $request->input('image2');
         $description = $request->input('description');
         $team_name = $request->input('team_name', '');
         $team_id = $team_name === '' ? $request->input('team_id') : $this->create_new_team($team_name);
         $role_ids = $request->input('role_ids', []);
         $user->update(compact('username', 'email', 'firstname', 'lastname', 'image1', 'image2', 'description', 'team_id'));
         if ($password !== '') {
             $user->password = bcrypt($password);
             $user->save();
         }
         $user->roles()->sync(gettype($role_ids) === 'array' ? $role_ids : []);
         return;
     }
     return redirect(action('UsersController@index'));
 }
Esempio n. 3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateUserRequest $request)
 {
     if ($this->captchaCheck() == false) {
         return redirect()->back()->withErrors(['Wrong Captcha'])->withInput();
     }
     if ($request->ajax()) {
         DB::beginTransaction();
         $vcode = "";
         $otp = "";
         try {
             $indUser = new Induser();
             $indUser->fname = $request['fname'];
             $indUser->lname = $request['lname'];
             $indUser->email = $request['email'];
             $indUser->mobile = $request['mobile'];
             if ($request['email'] != null) {
                 $vcode = 'A' . rand(1111, 9999);
                 $indUser->email_vcode = $vcode;
             }
             if ($request['mobile'] != null) {
                 $otp = rand(1111, 9999);
                 $indUser->mobile_otp = $otp;
             }
             $indUser->save();
             $user = new User();
             $user->name = $request['fname'] . ' ' . $request['lname'];
             $user->email = $request['email'];
             $user->mobile = $request['mobile'];
             $user->password = bcrypt($request['password']);
             $user->identifier = 1;
             if ($request['email'] != null) {
                 // $vcode = 'A'.rand(1111,9999);
                 $user->email_vcode = $vcode;
             }
             if ($request['mobile'] != null) {
                 // $otp = rand(1111,9999);
                 $user->mobile_otp = $otp;
             }
             $indUser->user()->save($user);
         } catch (\Exception $e) {
             DB::rollback();
             throw $e;
         }
         DB::commit();
         $data = array();
         if ($request['email'] != null) {
             $email = $request['email'];
             $fname = $request['fname'];
             $vcode = Induser::where('email', '=', $request['email'])->pluck('email_vcode');
             Mail::send('emails.welcome', array('fname' => $fname, 'vcode' => $vcode), function ($message) use($email, $fname) {
                 $message->to($email, $fname)->subject('Welcome to Jobtip!')->from('*****@*****.**', 'JobTip');
             });
             $data['vcode'] = 1;
         }
         if ($request['mobile'] != null) {
             $data['otp'] = $otp;
             // $smsMsg = "Thank you for registering Jobtip.in Your One Time Password (OTP) is ".$otp.". TnC applied. Visit www.jobtip.in";
             //    $data['delvStatus'] = SMS::send($request['mobile'], $smsMsg);
         }
         $data['page'] = 'login';
         return response()->json(['success' => true, 'data' => $data]);
         // return 'login';
     } else {
         DB::beginTransaction();
         try {
             $indUser = new Induser();
             $indUser->fname = $request['fname'];
             $indUser->lname = $request['lname'];
             $indUser->email = $request['email'];
             $indUser->mobile = $request['mobile'];
             if ($request['email'] != null) {
                 $vcode = 'A' . rand(1111, 9999);
                 $indUser->email_vcode = $vcode;
             }
             if ($request['mobile'] != null) {
                 $otp = rand(1111, 9999);
                 $indUser->mobile_otp = $otp;
             }
             $indUser->save();
             $user = new User();
             $user->name = $request['fname'] . ' ' . $request['lname'];
             $user->email = $request['email'];
             $user->mobile = $request['mobile'];
             $user->password = bcrypt($request['password']);
             $user->identifier = 1;
             $indUser->user()->save($user);
         } catch (\Exception $e) {
             DB::rollback();
             throw $e;
         }
         DB::commit();
         if ($request['email'] != null) {
             $email = $request['email'];
             $fname = $request['fname'];
             $vcode = Induser::where('email', '=', $request['email'])->pluck('email_vcode');
             Mail::send('emails.welcome', array('fname' => $fname, 'vcode' => $vcode), function ($message) use($email, $fname) {
                 $message->to($email, $fname)->subject('Welcome to Jobtip!')->from('*****@*****.**', 'JobTip');
             });
         }
         return redirect('/login');
     }
 }