ActiveRecord.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php namespace App\Http\Requests\Api\Lottery;
  2. use App\Http\Requests\BaseRequest;
  3. /**
  4. * 活动参与记录
  5. *
  6. */
  7. class ActiveRecord extends BaseRequest
  8. {
  9. /**
  10. * 获取应用于请求的规则
  11. *
  12. * @return array
  13. */
  14. public function rules()
  15. {
  16. // 编辑时排除ID
  17. // 返回结果
  18. return [
  19. // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
  20. // 验证字段,验证规则,提示信息
  21. // 'name' => 'string|max:20',
  22. 'id' => 'required|integer|gt:0',
  23. 'active_id' => 'required|integer|gt:0',
  24. ];
  25. }
  26. // 场景列表
  27. protected $scenes = [
  28. 'get_list' => ['active_id'],
  29. ];
  30. /**
  31. * 获取已定义验证规则的错误消息
  32. *
  33. * @return array
  34. */
  35. public function messages()
  36. {
  37. return [
  38. 'active_id.required' => '请选择活动ID',
  39. 'active_id.integer' => '活动ID有误',
  40. 'active_id.gt' => '活动ID有误',
  41. 'id.required' => '请选择奖品记录',
  42. 'id.integer' => '奖品记录ID有误',
  43. 'id.gt' => '奖品记录ID有误',
  44. ];
  45. }
  46. }