HouseLesseeProp.php 652 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. use think\Db;
  5. class HouseLesseeProp extends Validate{
  6. protected $rule = [
  7. 'title|名称' => 'require|checkUnique',
  8. ];
  9. protected $scene = [
  10. ];
  11. protected function checkUnique($value,$rule,$data=[])
  12. {
  13. $info = Db::name('house_lessee_prop')->where('title',$data['title'])->where('org_id',$data['org_id'])->find();
  14. if($data['id'] <= 0 && $info){
  15. return '名称已被使用';
  16. }
  17. if($info && $data['id'] > 0 && $info['id'] != $data['id']){
  18. return '名称已被使用';
  19. }
  20. return true;
  21. }
  22. }