UpdateRequest.php 782 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Requests\Client\User;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class UpdateRequest extends FormRequest
  5. {
  6. public function authorize(): bool
  7. {
  8. return true;
  9. }
  10. public function rules(): array
  11. {
  12. return [
  13. 'nickname' => 'nullable|string|max:50',
  14. 'avatar' => 'nullable|string|url|max:255',
  15. 'gender' => 'nullable|integer|in:0,1,2',
  16. ];
  17. }
  18. public function messages(): array
  19. {
  20. return [
  21. 'nickname.max' => '昵称不能超过50个字符',
  22. 'avatar.url' => '头像必须是有效的URL地址',
  23. 'gender.integer' => '性别必须是整数',
  24. 'gender.in' => '性别只能是0(未知)、1(男)或2(女)',
  25. ];
  26. }
  27. }