123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace app\common\validate;
- use think\Db;
- use think\Validate;
- class DinnerCompany extends Validate{
- protected $rule = [
- 'title|单位' => 'require|checkUnique',
- ];
- protected $message = [
- ];
- protected $scene = [
- ];
- protected function checkUnique($value,$rule,$data=[])
- {
- $info = Db::name('dinner_company')->where('title',$value)->where('del',0)->find();
- if($data['id'] <= 0 && $info){
- return '单位已被使用';
- }
- if($info && $data['id'] > 0 && $info['id'] != $data['id']){
- return '单位已被使用';
- }
- return true;
- }
- }
|