Redpacket.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php namespace App\Http\Requests\Admin\Custom;
  2. use App\Http\Requests\BaseRequest;
  3. /**
  4. * 入库验证器
  5. *
  6. */
  7. class Redpacket extends BaseRequest
  8. {
  9. /**
  10. * 获取应用于请求的规则
  11. *
  12. * @return array
  13. */
  14. public function rules()
  15. {
  16. // 编辑时排除ID
  17. // 返回结果
  18. return [
  19. // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
  20. // 验证字段,验证规则,提示信息
  21. 'id' => 'required|integer|gt:0',
  22. 'redpacket_id' => 'required|integer|gt:0',
  23. 'custom_codes' => 'required',
  24. 'status' => 'required|integer|gte:0',
  25. ];
  26. }
  27. // 场景列表
  28. protected $scenes = [
  29. 'add' => ['redpacket_id','custom_codes'],
  30. 'set_status' => ['id','status'],
  31. ];
  32. /**
  33. * 获取已定义验证规则的错误消息
  34. *
  35. * @return array
  36. */
  37. public function messages()
  38. {
  39. return [
  40. 'id.required' => 'ID未知',
  41. 'id.integer' => 'ID格式错误',
  42. 'id.gt' => 'ID格式错误',
  43. 'redpacket_id.required' => '请选择红包活动',
  44. 'redpacket_id.integer' => '活动ID格式错误',
  45. 'redpacket_id.gt' => '活动ID格式错误',
  46. 'custom_codes.required' => '请填写发放对象用户编码',
  47. 'status.required' => '请选择状态',
  48. 'status.integer' => '状态格式错误',
  49. 'status.gte' => '状态格式错误',
  50. ];
  51. }
  52. }