OrderAutoSendArea.php 767 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class OrderAutoSendArea extends Validate{
  6. protected $rule = [
  7. 'dep_id|部门' => 'require|checkUnique',
  8. 'user_id|维修人员' => 'require',
  9. ];
  10. protected $message = [
  11. ];
  12. protected $scene = [
  13. ];
  14. protected function checkUnique($value,$rule,$data=[])
  15. {
  16. $info = Db::name('order_auto_send_area')->where('dep_id',$value)
  17. ->where('org_id',$data['org_id'])
  18. ->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. }