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