StoreProfile.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Http\Requests\User;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class StoreProfile extends FormRequest
  5. {
  6. /**
  7. * Determine if the user is authorized to make this request.
  8. */
  9. public function authorize(): bool
  10. {
  11. return auth()->check();
  12. }
  13. /**
  14. * Get the validation rules that apply to the request.
  15. *
  16. * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
  17. */
  18. public function rules(): array
  19. {
  20. return [
  21. 'name' => 'string|required|min:2',
  22. 'phone' => 'nullable|string',
  23. 'current_password' => 'nullable',
  24. 'password' => 'nullable|min:8|confirmed',
  25. ];
  26. }
  27. public function messages(): array
  28. {
  29. return [
  30. 'password' => 'Пароль должен быть не менее 8 символов!',
  31. 'name' => 'Имя обязательно и не менее 2 символов!',
  32. ];
  33. }
  34. }