UpdateRequest.php 850 B

123456789101112131415161718192021222324252627282930313233
  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. 'gender' => 'nullable|integer|in:0,1,2',
  15. 'avatar' => 'nullable|string|url|max:255',
  16. ];
  17. }
  18. public function messages(): array
  19. {
  20. return [
  21. 'nickname.max' => '昵称不能超过50个字符',
  22. 'gender.integer' => '性别必须是整数',
  23. 'gender.in' => '性别只能是0(未知)、1(男)或2(女)',
  24. // 'avatar.url' => '头像必须是有效的URL地址',
  25. 'avatar.max' => '头像URL不能超过255个字符',
  26. ];
  27. }
  28. }