OfficialSeal.php 820 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class OfficialSeal extends Validate{
  6. protected $rule = [
  7. 'title|公章名称' => 'require|checkUnique',
  8. 'type' => 'require|in:1,2,3,4,5'
  9. ];
  10. protected $message = [
  11. 'type.require' => '未选择类型',
  12. 'type.in' => '未选择类型',
  13. ];
  14. protected $scene = [
  15. ];
  16. protected function checkUnique($value,$rule,$data=[])
  17. {
  18. $info = Db::name('official_seal')->where('title',$value)->where('org_id',$data['org_id'])->where('del',0)->find();
  19. if($data['id'] <= 0 && $info){
  20. return '名称已被使用';
  21. }
  22. if($info && $data['id'] > 0 && $info['id'] != $data['id']){
  23. return '名称已被使用';
  24. }
  25. return true;
  26. }
  27. }