Laravel (1) registration rewrite

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.