UnitPartnerRequest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class UnitPartnerRequest extends FormRequest
  5. {
  6. public function rules(): array
  7. {
  8. $isCreate = $this->isMethod('POST');
  9. $rules = [
  10. 'unit_id' => 'sometimes|required|integer|exists:units,id',
  11. 'name' => 'sometimes|required|string|max:255',
  12. 'social_name' => 'sometimes|nullable|string|max:255',
  13. 'role' => 'sometimes|nullable|string|max:100',
  14. 'cpf' => 'sometimes|required|string|max:20',
  15. 'rg' => 'sometimes|nullable|string|max:30',
  16. 'birth_date' => 'sometimes|nullable|date',
  17. 'participation' => 'sometimes|nullable|numeric|min:0|max:100',
  18. 'email' => 'sometimes|nullable|email|max:255',
  19. 'secondary_email' => 'sometimes|nullable|email|max:255',
  20. 'phone_number' => 'sometimes|nullable|string|max:20',
  21. 'cell_number' => 'sometimes|nullable|string|max:20',
  22. 'postal_code' => 'sometimes|nullable|string|max:9',
  23. 'street' => 'sometimes|nullable|string|max:255',
  24. 'address_number' => 'sometimes|nullable|string|max:20',
  25. 'neighborhood' => 'sometimes|nullable|string|max:255',
  26. 'complement' => 'sometimes|nullable|string|max:255',
  27. 'city_id' => 'sometimes|nullable|integer|exists:cities,id',
  28. 'state_id' => 'sometimes|nullable|integer|exists:states,id',
  29. 'avatar' => 'sometimes|nullable|image|max:2048',
  30. ];
  31. if ($isCreate) {
  32. $rules['unit_id'] = 'required|integer|exists:units,id';
  33. $rules['name'] = 'required|string|max:255';
  34. $rules['cpf'] = 'required|string|max:20';
  35. }
  36. return $rules;
  37. }
  38. }