Information Verification and Language Pack in Laravel

Source: Internet
Author: User

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']),]);}




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.