123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace app\common\validate;
- use think\Validate;
- use think\Db;
- class NoticeUserTemp extends Validate{
- protected $rule =[
- 'title|标题' => 'require|checkUnique',
- 'userids|接收人' => 'require',
- ];
- protected $message = [
- ];
- protected $scene = [
- ];
- protected function checkUnique($value,$rule,$data=[])
- {
- $info = Db::name('notice_user_temp')->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;
- }
- }
|