32 lines
798 B
PHP
32 lines
798 B
PHP
<?php
|
|
namespace app\business\validate;
|
|
use think\facade\Db;
|
|
use think\Validate;
|
|
|
|
class BusinessCheck extends Validate
|
|
{
|
|
// 自定义验证规则
|
|
protected function checkOne($value,$rule,$data=[])
|
|
{
|
|
$count = Db::name('Business')->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'],
|
|
];
|
|
}
|