Information Verification and Language Pack in Laravel
First, let's talk about the Language Pack.
1. Install the Language Pack through composer.
composer require "overtrue/laravel-lang:dev-master"
2. After the installation is successful, modify the configuration in config/app. php,
'Illuminate\Translation\TranslationServiceProvider'
Change to 'overtrue \ LaravelLang \ TranslationServiceProvider ',
3. Change the configuration.
["Numeric" => "password at least: min. "," string "=>" password must be at least min. ",]," confirmed "=>" inconsistent two passwords ",];
You can also create a zh-CN folder under resouces/lang/at the same level as the en folder in 'locale' => 'zh-cn. add the content to the php file and use it later.
["Numeric" => "password at least: min. "," string "=>" password must be at least min. ",]," confirmed "=>" inconsistent two passwords ",];
Let's talk about how to add verification information to the file header.
Use App \ Services \ Registrar; for example, I want to create a function createUser () {$ data = array ('name' => 'admins ', 'email '=> 'admin @ admin. comd ', 'Password' => '000000'); $ register = new Registrar; $ validator = $ register-> validator ($ data ); // verify the input information if (! $ Validator-> fails () {$ result = $ register-> create ($ data); if ($ result) {return array ('code' => 1, 'info' => 'user created successfully') ;}} else {$ messages = $ validator-> messages (); return array ('code' => 0, 'info' => $ messages-> first () ;}} the Registrar class is written as follows, which is almost unchanged by default.
'Required | max: 000000', 'email '=> 'required | email | max: 255 | unique: users', 'Password' => 'required | min: 6',]); return $ validator;}/*** Create a new user instance after a valid registration. ** @ param array $ data * @ return User */public function create (array $ data) {return User :: create (['name' => $ data ['name'], 'email '=> $ data ['email'], 'Password' => bcrypt ($ data ['Password']),]);}