0
0

MateCheck.php 801 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class MateCheck extends Validate{
  6. protected $rule = [
  7. 'goods' => 'checkGoods'
  8. ];
  9. protected $message = [
  10. ];
  11. protected $scene = [
  12. ];
  13. protected function checkGoods($value,$rule,$data=[]){
  14. if(!isset($data['goods'])||empty($data['goods'])){
  15. return '未选择物品';
  16. }
  17. foreach ($data['goods'] as $k=>$v){
  18. $info = Db::name('mate_goods')
  19. ->where('org_id',$data['org_id'])
  20. ->where('id',$v)
  21. ->where('enable',1)
  22. ->where('del',0)
  23. ->find();
  24. if(!$info){
  25. return '选择的物品不存在';
  26. }
  27. }
  28. return true;
  29. }
  30. }