CouponSave.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. 'expired_at' => 'required|integer',
  18. 'limit_use' => 'nullable|integer'
  19. ];
  20. }
  21. public function messages()
  22. {
  23. return [
  24. 'name.required' => '名称不能为空',
  25. 'type.required' => '类型不能为空',
  26. 'type.in' => '类型格式有误',
  27. 'value.required' => '金额或比例不能为空',
  28. 'value.integer' => '金额或比例格式有误',
  29. 'expired_at.required' => '过期时间不能为空',
  30. 'expired_at.integer' => '过期时间格式有误',
  31. 'limit_use.integer' => '使用次数格式有误'
  32. ];
  33. }
  34. }