RegisterClientRequest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class RegisterClientRequest extends FormRequest
  5. {
  6. public function rules(): array
  7. {
  8. return [
  9. 'code' => 'required|string|max:6',
  10. 'email' => 'required|string|email|max:255',
  11. 'name' => 'required|string|max:255',
  12. 'phone' => 'required|string|max:20',
  13. 'document' => 'required|string|max:20',
  14. 'zip_code' => 'required|string|max:20',
  15. 'number' => 'required|string|max:20',
  16. 'address' => 'required|string|max:255',
  17. 'district' => 'required|string|max:255',
  18. 'city' => 'required|string|max:255',
  19. 'state' => 'required|string|max:10',
  20. 'has_complement' => 'required|boolean',
  21. 'complement' => 'sometimes|nullable|string|max:255',
  22. 'nickname' => 'sometimes|nullable|string|max:255',
  23. 'instructions' => 'sometimes|nullable|string|max:500',
  24. 'address_type' => 'sometimes|nullable|string|in:home,commercial,other',
  25. 'latitude' => 'sometimes|nullable|numeric',
  26. 'longitude' => 'sometimes|nullable|numeric',
  27. 'avatar' => 'sometimes|nullable|file|image|mimes:jpg,jpeg,png,webp|max:5120',
  28. ];
  29. }
  30. protected function prepareForValidation(): void
  31. {
  32. if (! $this->filled('has_complement')) {
  33. $this->merge(['has_complement' => false]);
  34. }
  35. }
  36. }