1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace app\common\validate;
- use think\Db;
- use think\Validate;
- class OfficialSeal extends Validate{
- protected $rule = [
- 'title|公章名称' => 'require|checkUnique',
- 'type' => 'require|in:1,2,3,4,5'
- ];
- protected $message = [
- 'type.require' => '未选择类型',
- 'type.in' => '未选择类型',
- ];
- protected $scene = [
- ];
- protected function checkUnique($value,$rule,$data=[])
- {
- $info = Db::name('official_seal')->where('title',$value)->where('org_id',$data['org_id'])->where('del',0)->find();
- if($data['id'] <= 0 && $info){
- return '名称已被使用';
- }
- if($info && $data['id'] > 0 && $info['id'] != $data['id']){
- return '名称已被使用';
- }
- return true;
- }
- }
|