Laravel (1) Register and rewrite the configuration route
Php
'Auth \ authcontroller',]); "this routing configuration method corresponds to the path method of access + method name. for example, if you use the get method in the browser to access the register method, the route will be automatically configured to the getRegister method under this class.. The same is true for post. ##### create a registration page for myself. I create my own view in AuthControlle. "php
All (); $ data ['register _ IP'] = $ req-> ip (); $ user = $ this-> registrar-> create ($ data ); return redirect ()-> intended ('/');}?>
You will find that the entire registration function is very simple. Where can I set registration restrictions?
In fact, all the filled form data is controlled in the UserRegisterRequest file.
Php
['Required', 'min: 3', 'Max: 16', 'Unique: users'], "phone_number" => ['required', 'min: 3 ', 'Max: 16', 'Unique: users'], "password" => ['requestred', 'min: 6', 'Max: 16', 'firmed '], "verify_code" => ['required', 'digits: 4'],];} public function sanitize () {return $ this-> all ();}}
We can use the php artisan make: request provided by laravel to create a request class.
This class can control the data of all requests, and define rules in the rule to control the data of the request. if the rules are met, the access will continue.
Modify registration and add data
The purpose of registration is to write qualified data into the user table. since the requested data is rewritten, the request operation must also be rewritten.
After the registration is successful, the code in the above postRegister is added to the user database.
php
registrar->create($data);
Find this code. this code is located in Registrar. php under services.
php
$data['username'], 'password' => bcrypt($data['password']), 'register_time' => Carbon::now()->toDateTimeString(), 'register_ip' => $data['register_ip'] ]; return User::create($properties); $user = new User(); $user->save(); }
Just change the processing function to a function that conforms to your own business logic.
Laravel step-by-step permission control (2) logon rewriting