CouponSave.php 1.4 KB

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