Package Data | |
---|---|
Maintainer Username: | 5-say |
Maintainer Contact: | bcw.5@foxmail.com (FiveSay) |
Package Create Date: | 2016-01-14 |
Package Last Update: | 2016-08-21 |
Home Page: | |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-11-23 03:10:07 |
Package Statistics | |
---|---|
Total Downloads: | 54 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
基于 trait 的 laravel 模型特性拓展:[ packagist ]
创建新数据时,对所有规则进行验证。
更新数据时,仅针对脏数据进行验证。(从根本上避免类似于unique
这种特殊规则在编辑时遇到的“需额外参数以排除自身”的问题)
composer require five-say/laravel-model-ext-trait
<?php
use FiveSay\Laravel\Model\ExtTrait;
class User
{
use ExtTrait;
/**
* 数据校验规则
* @var array
*/
public $rules = [
'name' => [
'required' => '请填写用户名',
],
'email' => [
'required' => '请填写 email',
'email' => 'email 格式不正确',
'unique:users' => 'email 已被占用',
],
];
}