| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App\Http\Requests;
- use App\Enums\WorkingPeriodEnum;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Validation\Rule;
- class RegisterProviderRequest extends FormRequest
- {
- public function rules(): array
- {
- $rules = [
- 'email' => 'sometimes|email',
- 'phone' => 'sometimes|string|nullable|max:20',
- 'name' => 'required|string|max:255',
- 'code' => 'required|string|max:6',
- 'document' => ['required', 'string', 'max:20'],
- 'rg' => 'required|string|max:20',
- 'birth_date' => 'required|date|before:today',
- 'recipient_name' => 'required|string|max:255',
- 'recipient_email' => 'required|email|max:255',
- 'recipient_description' => 'required|string',
- 'recipient_document' => 'required|string|max:20',
- 'recipient_type' => ['required', Rule::in(['individual', 'company'])],
- 'recipient_code' => 'required|string|max:255',
- 'recipient_payment_mode' => ['required', Rule::in(['bank_transfer'])],
- 'recipient_default_bank_account' => 'required|array',
- 'recipient_default_bank_account.holder_name' => 'required|string|max:255',
- 'recipient_default_bank_account.holder_type' => ['required', Rule::in(['individual', 'company'])],
- 'recipient_default_bank_account.holder_document' => 'required|string|max:20',
- 'recipient_default_bank_account.bank' => 'required|string|max:20',
- 'recipient_default_bank_account.branch_number' => 'required|string|max:20',
- 'recipient_default_bank_account.branch_check_digit' => 'sometimes|nullable|string|max:10',
- 'recipient_default_bank_account.account_number' => 'required|string|max:20',
- 'recipient_default_bank_account.account_check_digit' => 'required|string|max:10',
- 'recipient_default_bank_account.type' => ['required', Rule::in(['checking', 'savings'])],
- 'recipient_default_bank_account.metadata' => 'sometimes|array',
- 'recipient_default_bank_account.pix_key' => 'sometimes|nullable|string|max:255',
- 'recipient_metadata' => 'sometimes|array',
- 'zip_code' => 'required|string|max:20',
- 'address' => 'required|string|max:255',
- 'has_complement' => 'sometimes|boolean',
- 'complement' => 'nullable|string|max:255',
- 'nickname' => 'nullable|string|max:255',
- 'instructions' => 'nullable|string',
- 'address_type' => ['required', Rule::in(['home', 'commercial', 'other'])],
- 'city' => 'nullable|string|max:255',
- 'state' => 'nullable|string|max:2',
- 'daily_price_8h' => 'required|numeric|min:100|max:500',
- 'daily_price_6h' => 'required|numeric|min:0',
- 'daily_price_4h' => 'required|numeric|min:0',
- 'daily_price_2h' => 'required|numeric|min:0',
- 'services_types_ids' => 'sometimes|array',
- 'services_types_ids.*' => [
- 'integer',
- Rule::exists('service_types', 'id')->where(function ($query) {
- $query->whereNull('deleted_at')->where('is_active', true);
- }),
- ],
- 'service_types_ids' => 'sometimes|array',
- 'service_types_ids.*' => [
- 'integer',
- Rule::exists('service_types', 'id')->where(function ($query) {
- $query->whereNull('deleted_at')->where('is_active', true);
- }),
- ],
- 'working_days' => 'required|array|min:1',
- 'working_days.*.day' => 'required|integer|min:0|max:6',
- 'working_days.*.period' => ['required', Rule::in([WorkingPeriodEnum::MORNING->value, WorkingPeriodEnum::AFTERNOON->value])],
- 'selfie_base64' => 'required|string',
- 'document_front_base64' => 'required|string',
- 'document_back_base64' => 'required|string',
- ];
- if (!$this->has('email')) {
- $rules['phone'] = 'required|string|max:20';
- $rules['email'] = 'nullable';
- }
- if (!$this->has('phone')) {
- $rules['email'] = 'required|email';
- $rules['phone'] = 'nullable';
- }
- return $rules;
- }
- }
|