UserUpdate.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Http\Requests\Admin;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class UserUpdate 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. 'email' => 'required|email',
  15. 'transfer_enable' => 'numeric',
  16. 'expired_at' => 'integer',
  17. 'banned' => 'required|in:0,1',
  18. 'is_admin' => 'required|in:0,1',
  19. 'plan_id' => 'integer',
  20. 'commission_rate' => 'nullable|integer|min:0|max:100',
  21. 'discount' => 'nullable|integer|min:0|max:100'
  22. ];
  23. }
  24. public function messages()
  25. {
  26. return [
  27. 'email.required' => '邮箱不能为空',
  28. 'email.email' => '邮箱格式不正确',
  29. 'transfer_enable.numeric' => '流量格式不正确',
  30. 'expired_at.integer' => '到期时间格式不正确',
  31. 'banned.required' => '是否封禁不能为空',
  32. 'banned.in' => '是否封禁格式不正确',
  33. 'is_admin.required' => '是否管理员不能为空',
  34. 'is_admin.in' => '是否管理员格式不正确',
  35. 'plan_id.integer' => '订阅计划格式不正确',
  36. 'commission_rate.integer' => '推荐返利比例格式不正确',
  37. 'commission_rate.nullable' => '推荐返利比例格式不正确',
  38. 'commission_rate.min' => '推荐返利比例最小为0',
  39. 'commission_rate.max' => '推荐返利比例最大为100',
  40. 'discount.integer' => '专属折扣比例格式不正确',
  41. 'discount.nullable' => '专属折扣比例格式不正确',
  42. 'discount.min' => '专属折扣比例最小为0',
  43. 'discount.max' => '专属折扣比例最大为100'
  44. ];
  45. }
  46. }