1.禁止操作数据表之后更新created_at和updated_at字段,在相应的模型中定义

2.设置模型中自动维护时间字段

3.使用Form Request 对提交到控制器的表单数据进行规则验证
php artisan make:request RegisterFormRequest //生成相应的认证文件,里面定义rules,messages等信息

然后在需要验证的控制器上传入request参数 如图:

1.禁止操作数据表之后更新created_at和updated_at字段,在相应的模型中定义
2.设置模型中自动维护时间字段
3.使用Form Request 对提交到控制器的表单数据进行规则验证
php artisan make:request RegisterFormRequest //生成相应的认证文件,里面定义rules,messages等信息
然后在需要验证的控制器上传入request参数 如图:
本文标题:laravel 小技巧
本文链接:https://www.haomeiwen.com/subject/pamgmftx.html
网友评论