DinnerGroup.php 784 B

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