Fields.php
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace app\admin\validate\cms;
use think\Validate;
class Fields extends Validate
{
/**
* 验证规则
*/
protected $rule = [
'name|名称' => 'require|unique:cms_fields,model_id^name',
'title|管理员' => 'require',
'model_id|模型ID' => 'require|integer',
'status|状态' => 'require|in:normal,hidden',
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [
'name', 'title', 'model_id', 'status'
],
'edit' => [
'name', 'title', 'model_id', 'status'
],
];
public function __construct(array $rules = array(), $message = array(), $field = array())
{
//如果是编辑模式,则排除下主键
$ids = request()->param("ids");
if ($ids)
{
$this->rule['name|名称'] .= ",{$ids}";
}
parent::__construct($rules, $message, $field);
}
}