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