ApproveUse.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. /**
  5. * 领用信息验证
  6. */
  7. class ApproveUse extends Validate
  8. {
  9. /**
  10. * 验证规则
  11. */
  12. protected $rule = [
  13. 'use_goods' => 'require',
  14. 'reason' => 'require',
  15. 'approve_user' => 'require',
  16. ];
  17. /**
  18. * 提示消息
  19. */
  20. protected $message = [
  21. ];
  22. /**
  23. * 验证场景
  24. */
  25. protected $scene = [
  26. 'create' => ['use_goods','approve_user'],
  27. 'update' => ['use_goods','approve_user'],
  28. 'edit' => ['use_goods'],
  29. ];
  30. /**
  31. * 构造函数
  32. * @access public
  33. * @param array $rules 验证规则
  34. * @param array $message 验证提示信息
  35. * @param array $field 验证字段描述信息
  36. */
  37. public function __construct(array $rules = [], $message = [], $field = [])
  38. {
  39. $this->field = [
  40. 'use_goods' => '领用物品',
  41. 'reason' => '物品用途',
  42. 'approve_user' => '审批人',
  43. ];
  44. $this->message = array_merge($this->message, [
  45. 'apply_goods.require' => '请添加领用物品',
  46. ]);
  47. parent::__construct($rules, $message, $field);
  48. }
  49. }