CouponSave.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Http\Requests\Admin;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class CouponSave extends FormRequest
  5. {
  6. const RULES = [
  7. 'name' => 'required',
  8. 'type' => 'required|in:1,2',
  9. 'value' => 'required|integer',
  10. 'started_at' => 'required|integer',
  11. 'ended_at' => 'required|integer',
  12. 'limit_use' => 'nullable|integer',
  13. 'limit_plan_ids' => 'nullable|array'
  14. ];
  15. /**
  16. * Get the validation rules that apply to the request.
  17. *
  18. * @return array
  19. */
  20. public function rules()
  21. {
  22. return self::RULES;
  23. }
  24. public function messages()
  25. {
  26. return [
  27. 'name.required' => '名称不能为空',
  28. 'type.required' => '类型不能为空',
  29. 'type.in' => '类型格式有误',
  30. 'value.required' => '金额或比例不能为空',
  31. 'value.integer' => '金额或比例格式有误',
  32. 'started_at.required' => '开始时间不能为空',
  33. 'started_at.integer' => '开始时间格式有误',
  34. 'ended_at.required' => '结束时间不能为空',
  35. 'ended_at.integer' => '结束时间格式有误',
  36. 'limit_use.integer' => '使用次数格式有误',
  37. 'limit_plan_ids.array' => '指定订阅格式有误'
  38. ];
  39. }
  40. }