当前位置:网站首页>Use of laravel verifier
Use of laravel verifier
2022-06-24 23:12:00 【Wang Daochang's way of programming】
One 、 Three ways to use the verifier
1.1 Verifier class
php artisan make:request DemoRequest
Then the framework will generate a Request/DemoRequest.php The catalog file for
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class DemoRequest extends FormRequest{
public function authorize(){
return false;
}
public function rules(){
return [];
}
public function messages(){
return [];
}
}
1.2 controller Layer built-in verifier
Democontroller.php In file
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class DemoController extends Controller{
public function index(Request $request){
$this->validate();
}
}
1.3 Verifier facade
$validate = Validator::make();
# Judge whether the verification is passed fails()/
if($validate->fails()){
var_dump($validate->getMessageBag()->getMessages())
}
Two 、 Custom validator
2.1 Generate by command
php artisan make:rule DemoValidate
model event
Model Time :https://blog.csdn.net/qq_37868757/article/details/107043935
3、 ... and 、 Verify that the attributes are translated into Chinese
3.1 Download font library
Download and switch font library :
First you need to download Font library
When the download is complete , In the compressed package src/zh-CN The folder is copied to the project directory resources/lang Under the folder .
modify config->app.php file , Modify the code as follows :
'locale' => 'zh-CN',
because captcha There is no Chinese explanation in the Chinese bag , So you need to manually add Chinese explanations , The specific operation is as follows :
open resources/zh-CN/validation.php, Add the following key value pairs to the total array :
'captcha' => ':attribute Incorrect .',
stay attributes The following key value pairs are appended to the array :
'captcha' => ' Verification Code ',
边栏推荐
- laravel 验证器的使用
- 2022 safety officer-b certificate examination question bank and answers
- 动态菜单,自动对齐
- How should we measure agile R & D projects?
- 推送Markdown格式信息到釘釘機器人
- Research and investment strategy report on China's bridge anticorrosive coating industry (2022 Edition)
- Financial management [2]
- . Net 7 Preview 1 has been officially released
- Servlet
- The large-scale market of graduate dormitory! Here comes the enviable graduate dormitory!
猜你喜欢

The large-scale market of graduate dormitory! Here comes the enviable graduate dormitory!

Online group chat and dating platform test point

laravel 宝塔安全配置

Cases of addition, deletion, modification and search of C # learning for two years and C # import and export (de duplication)

03_SpingBoot 核心配置文件

京东618会议平板排行榜公布,新锐黑马品牌会参谋角逐前三名,向国货老大华为学习

03_ Spingboot core profile

【文本数据挖掘】中文命名实体识别:HMM模型+BiLSTM_CRF模型(Pytorch)【调研与实验分析】

A big factory interview must ask: how to solve the problem of TCP reliable transmission? 8 pictures for you to learn in detail

2022 safety officer-b certificate examination question bank and answers
随机推荐
Financial management [5]
Accounting standards for business enterprises application [5]
China solar thermal market trend report, technical dynamic innovation and market forecast
是否需要提高代码阅读能力?这有技巧
Tech Talk 活动回顾|云原生 DevOps 的 Kubernetes 技巧
Laravel add helper file
The large-scale market of graduate dormitory! Here comes the enviable graduate dormitory!
02_ Springboot starter case
It's hard to hear C language? Why don't you take a look at my article (7) input and output
Research Report on market supply and demand and strategy of China's solar charging controller industry
laravel model 注意事项
2022 safety officer-a certificate examination questions and answers
Dig deep into MySQL - resolve the non clustered index of MyISAM storage engine
JD 618 conference tablet ranking list announced that the new dark horse brand staff will compete for the top three, learning from Huawei, the leader of domestic products
Getting started with the go Cobra command line tool
2022年高压电工考试模拟100题及在线模拟考试
Financial management [6]
非单文件组件
laravel 宝塔安全配置
2022年安全员-A证考题及答案