Example #1
0
 public function store()
 {
     $validator = Validator::make(Input::all(), ['pack' => 'required|exists:products,id', 'name' => 'required|min:6|max:18', 'lastname' => 'required', 'birthday' => 'required', 'user' => 'required|unique:users,user|min:6|max:18', 'country' => 'required', 'email' => 'required|confirmed', 'password' => 'required|confirmed', 'phone' => 'required']);
     if ($validator) {
         if ($new_user = User::create(['user' => Input::get('user'), 'password' => Hash::make(Input::get('password')), 'email' => Input::get('email'), 'name' => Input::get('name'), 'lastname' => Input::get('lastname'), 'birthday' => Input::get('birthday'), 'phone' => Input::get('phone'), 'address' => Input::has('address') ? Input::get('address') : '---', 'renew' => date('Y-m-d'), 'product_id' => Input::get('pack'), 'rol_id' => 1, 'status' => 'pending', 'skype' => Input::has('skype') ? Input::get('skype') : '', 'whatsapp' => Input::has('whatsapp') ? Input::get('whatsapp') : '', 'country_id' => Input::has('country') ? Input::get('country') : 0])) {
             $new_user->trees()->create(['parent_id' => 0, 'position' => 0, 'sponsor_id' => auth()->user()->id, 'matrix_parent' => 0, 'matrix_position' => 0, 'product_id' => Input::get('pack')]);
             $new_user->wallets()->create(['activation' => 0, 'commission' => 0, 'auction' => 0, 'utilities' => 0, 'balance' => 0, 'responsible_id' => 0]);
             //se llama el job para enviar correo confirmacion
             $this->dispatch(new NewUserMailJob(['name' => Input::get('name'), 'lastname' => Input::get('lastname'), 'user' => Input::get('user'), 'email' => Input::get('email'), 'password' => Input::get('password')]));
             return redirect()->route('members.payment', ['id' => $new_user->id]);
         }
     } else {
         return redirect()->route('members.register')->withErrors($validator);
     }
 }
Example #2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }