/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $reglas = array('name' => 'required', 'email' => 'required|unique:users', 'type' => 'required|in:user,admin'); $this->validate($request, $reglas); $nuevo = new User($request->all()); $nuevo->password = bcrypt($request->get('password')); $nuevo->save(); return \Redirect::route('Admin.user.index'); }
/** * 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']), ]);*/ /*$user = new User([ 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), ]);*/ $user = new User(\Request::all()); $user->type = 'user'; $user->save(); return $user; }