/** * Process a post request, creating a new user * * Note: we don't just create using the raw request data because the password * needs to be encrypted */ public function store(Request $request) { $data = $request->all(); User::create(['name' => $data['name'], 'username' => $data['username'], 'role' => $data['role'], 'email' => $data['email'], 'phone' => $data['phone'], 'color' => $data['color'], 'password' => bcrypt($data['password'])]); // after we create the user, go to the directory return redirect('directory'); }
/** * 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'], 'username' => $data['username'], 'role' => $data['role'], 'email' => $data['email'], 'phone' => $data['phone'], 'color' => $data['color'], 'password' => bcrypt($data['password'])]); }