Receipt.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php namespace App\Http\Requests\Admin\Orders;
  2. use App\Http\Requests\BaseRequest;
  3. /**
  4. * 类型验证器
  5. *
  6. */
  7. class Receipt extends BaseRequest
  8. {
  9. /**
  10. * 获取应用于请求的规则
  11. *
  12. * @return array
  13. */
  14. public function rules()
  15. {
  16. // 返回结果
  17. return [
  18. // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
  19. // 验证字段,验证规则,提示信息
  20. 'remark' => 'required',
  21. 'id' => 'required|integer|gt:0',
  22. ];
  23. }
  24. // 场景列表
  25. protected $scenes = [
  26. 'allow' => ['id'],
  27. 'refuse' => ['id','remark'],
  28. ];
  29. /**
  30. * 获取已定义验证规则的错误消息
  31. *
  32. * @return array
  33. */
  34. public function messages()
  35. {
  36. return [
  37. 'remark.required' => '拒绝原因必填',
  38. 'id.required' => 'ID未知',
  39. 'id.integer' => 'ID格式错误',
  40. 'id.gt' => 'ID格式错误',
  41. ];
  42. }
  43. }