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