表单请求验证
- 引入UserRequest库
php artisan make:request UserRequest
- 执行以上代码生成app/http/RequestsUserRequest.php文件,在此文件中有权限验证方法authorize和验证规则方法rule,在rule方法中添加验证规则:
'name' => 'required|between:3,25|regex:/^[A-Za-z0-9\-\_]+$/|unique:users,name,' . Auth::id(),
'email' => 'required|email',
'introduction' => 'max:80',
引入中文语言包依赖
composer require "overtrue/laravel-lang:~3.0"
网友评论