first commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace app\information\validate;
|
||||
|
||||
use think\facade\Db;
|
||||
use think\Validate;
|
||||
|
||||
class InformationCheck extends Validate
|
||||
{
|
||||
// 自定义验证规则
|
||||
protected function checkOne($value, $rule, $data = [])
|
||||
{
|
||||
$count = Db::name('Information')->where(['name' => $data['name'], 'delete_time' => 0])->count();
|
||||
return $count == 0 ? true : false;
|
||||
}
|
||||
|
||||
protected $rule = [
|
||||
'maincontact' => 'require|checkOne',
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'name.require' => '联系人姓名不能为空',
|
||||
// 'name.checkOne' => '同样的商务信息已经存在',
|
||||
'maincontact.checkOne' => '同样的商务信息已经存在',
|
||||
'id.require' => '缺少更新条件',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['name'],
|
||||
'edit' => ['id'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user