classRegisterControllerextendsController { /* |-------------------------------------------------------------------------- | Register Controller |-------------------------------------------------------------------------- | | This controller handles the registration of new users as well as their | validation and creation. By default this controller uses a trait to | provide this functionality without requiring any additional code. | */ useRegistersUsers;
/** * Where to redirect users after registration. * * @var string */ protected$redirectTo = '/home';
/** * Create a new controller instance. * * @return void */ publicfunction__construct() { $this->middleware('guest'); }
/** * Get a validator for an incoming registration request. * * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ protectedfunctionvalidator(array$data) { returnValidator::make($data, [ 'name' => 'required|string|max:255', 'username' => 'required|string|max:20|unique:users', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:6|confirmed', ]); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return \App\User */ protectedfunctioncreate(array$data) { returnUser::create([ 'name' => $data['name'], 'username' => $data['username'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]); } }
classLoginControllerextendsController { /* |-------------------------------------------------------------------------- | Login Controller |-------------------------------------------------------------------------- | | This controller handles authenticating users for the application and | redirecting them to your home screen. The controller uses a trait | to conveniently provide its functionality to your applications. | */ useAuthenticatesUsers;
/** * Where to redirect users after login. * * @var string */ protected$redirectTo = '/home';
/** * Create a new controller instance. * * @return void */ publicfunction__construct() { $this->middleware('guest')->except('logout'); }