|
@@ -5,98 +5,78 @@ namespace App\Http\Requests;
|
|
|
use App\Enums\GenderEnum;
|
|
use App\Enums\GenderEnum;
|
|
|
use App\Enums\WorkingPeriodEnum;
|
|
use App\Enums\WorkingPeriodEnum;
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
-use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
|
|
class RegisterProviderRequest extends FormRequest
|
|
class RegisterProviderRequest extends FormRequest
|
|
|
{
|
|
{
|
|
|
- protected function prepareForValidation(): void
|
|
|
|
|
- {
|
|
|
|
|
- if (! $this->filled('has_complement')) {
|
|
|
|
|
- $this->merge(['has_complement' => false]);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public function rules(): array
|
|
public function rules(): array
|
|
|
{
|
|
{
|
|
|
$dailyPriceMin = config('provider.daily_price_min');
|
|
$dailyPriceMin = config('provider.daily_price_min');
|
|
|
|
|
|
|
|
$rules = [
|
|
$rules = [
|
|
|
- 'email' => 'sometimes|nullable|email',
|
|
|
|
|
- 'phone' => 'required|string|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',
|
|
|
|
|
- 'gender' => ['sometimes', 'nullable', Rule::enum(GenderEnum::class)],
|
|
|
|
|
|
|
+ 'code' => 'required|string|max:6',
|
|
|
|
|
+ 'email' => 'required|string|email|max:255',
|
|
|
|
|
+ 'name' => 'required|string|max:255',
|
|
|
|
|
+ 'phone' => 'required|string|max:20',
|
|
|
|
|
+ 'document' => 'required|string|max:20',
|
|
|
|
|
+ 'rg' => 'required|string|max:20',
|
|
|
|
|
+ 'gender' => 'required|string|in:'.implode(',', GenderEnum::toArray()),
|
|
|
|
|
+ 'birth_date' => 'required|date|before:today',
|
|
|
|
|
+
|
|
|
|
|
+ 'zip_code' => 'required|string|max:20',
|
|
|
|
|
+ 'number' => 'required|string|max:20',
|
|
|
|
|
+ 'address' => 'required|string|max:255',
|
|
|
|
|
+ 'district' => 'required|string|max:255',
|
|
|
|
|
+ 'city' => 'required|string|max:255',
|
|
|
|
|
+ 'state' => 'required|string|max:2',
|
|
|
|
|
+ 'address_type' => 'required|string|in:home,commercial,other',
|
|
|
|
|
+ 'has_complement' => 'required|boolean',
|
|
|
|
|
+
|
|
|
|
|
+ 'daily_price_8h' => "required|numeric|min:{$dailyPriceMin}|max:500",
|
|
|
|
|
+ 'daily_price_6h' => 'required|numeric|min:0',
|
|
|
|
|
+ 'daily_price_4h' => 'required|numeric|min:0',
|
|
|
|
|
+ 'daily_price_2h' => 'required|numeric|min:0',
|
|
|
|
|
+
|
|
|
|
|
+ 'selfie' => 'required|file|image|mimes:jpg,jpeg,png,webp|max:5120',
|
|
|
|
|
+ 'document_front' => 'required|file|image|mimes:jpg,jpeg,png,webp|max:10240',
|
|
|
|
|
+ 'document_back' => 'required|file|image|mimes:jpg,jpeg,png,webp|max:10240',
|
|
|
|
|
+
|
|
|
|
|
+ 'working_days' => 'required|array|min:1',
|
|
|
|
|
+ 'working_days.*.day' => 'required|integer|min:0|max:6',
|
|
|
|
|
+ 'working_days.*.period' => 'required|string|in:'.implode(',', array_column(WorkingPeriodEnum::cases(), 'value')),
|
|
|
|
|
+
|
|
|
|
|
+ 'complement' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
+ 'nickname' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
+ 'latitude' => 'sometimes|nullable|numeric',
|
|
|
|
|
+ 'longitude' => 'sometimes|nullable|numeric',
|
|
|
|
|
+ 'instructions' => 'sometimes|nullable|string',
|
|
|
|
|
|
|
|
- 'recipient_name' => 'sometimes|string|max:255',
|
|
|
|
|
- 'recipient_email' => 'sometimes|email|max:255',
|
|
|
|
|
- 'recipient_description' => 'sometimes|string',
|
|
|
|
|
- 'recipient_document' => 'sometimes|string|max:20',
|
|
|
|
|
- 'recipient_type' => ['sometimes', Rule::in(['individual', 'company'])],
|
|
|
|
|
|
|
+ //
|
|
|
|
|
|
|
|
- 'recipient_payment_mode' => ['sometimes', Rule::in(['bank_transfer'])],
|
|
|
|
|
|
|
+ 'recipient_email' => 'sometimes|string|email|max:255',
|
|
|
|
|
+ 'recipient_name' => 'sometimes|string|max:255',
|
|
|
|
|
+ 'recipient_document' => 'sometimes|string|max:20',
|
|
|
|
|
+ 'recipient_description' => 'sometimes|string',
|
|
|
|
|
+ 'recipient_type' => 'sometimes|string|in:individual,company',
|
|
|
|
|
+ 'recipient_payment_mode' => 'sometimes|string|in:bank_transfer',
|
|
|
|
|
|
|
|
- 'recipient_default_bank_account' => 'sometimes|array',
|
|
|
|
|
|
|
+ 'recipient_default_bank_account' => 'sometimes|array',
|
|
|
|
|
+
|
|
|
'recipient_default_bank_account.holder_name' => 'sometimes|string|max:255',
|
|
'recipient_default_bank_account.holder_name' => 'sometimes|string|max:255',
|
|
|
- 'recipient_default_bank_account.holder_type' => ['sometimes', Rule::in(['individual', 'company'])],
|
|
|
|
|
'recipient_default_bank_account.holder_document' => 'sometimes|string|max:20',
|
|
'recipient_default_bank_account.holder_document' => 'sometimes|string|max:20',
|
|
|
|
|
+ 'recipient_default_bank_account.holder_type' => 'sometimes|string|in:individual,company',
|
|
|
'recipient_default_bank_account.bank' => 'sometimes|string|max:3',
|
|
'recipient_default_bank_account.bank' => 'sometimes|string|max:3',
|
|
|
'recipient_default_bank_account.branch_number' => 'sometimes|string|max:20',
|
|
'recipient_default_bank_account.branch_number' => 'sometimes|string|max:20',
|
|
|
- 'recipient_default_bank_account.branch_check_digit' => 'sometimes|nullable|string|max:10',
|
|
|
|
|
|
|
+ 'recipient_default_bank_account.branch_check_digit' => 'sometimes|string|max:10',
|
|
|
'recipient_default_bank_account.account_number' => 'sometimes|string|max:20',
|
|
'recipient_default_bank_account.account_number' => 'sometimes|string|max:20',
|
|
|
'recipient_default_bank_account.account_check_digit' => 'sometimes|string|max:10',
|
|
'recipient_default_bank_account.account_check_digit' => 'sometimes|string|max:10',
|
|
|
- 'recipient_default_bank_account.type' => ['sometimes', Rule::in(['checking', 'savings'])],
|
|
|
|
|
|
|
+ 'recipient_default_bank_account.type' => 'sometimes|string|in:checking,savings',
|
|
|
'recipient_default_bank_account.metadata' => 'sometimes|array',
|
|
'recipient_default_bank_account.metadata' => 'sometimes|array',
|
|
|
- 'recipient_default_bank_account.pix_key' => 'sometimes|nullable|string|max:255',
|
|
|
|
|
|
|
+ 'recipient_default_bank_account.pix_key' => 'sometimes|string|nullable|max:255',
|
|
|
|
|
|
|
|
'recipient_metadata' => 'sometimes|array',
|
|
'recipient_metadata' => 'sometimes|array',
|
|
|
-
|
|
|
|
|
- 'zip_code' => 'required|string|max:20',
|
|
|
|
|
- 'address' => 'required|string|max:255',
|
|
|
|
|
- 'number' => 'required|string|max:20',
|
|
|
|
|
- 'district' => 'required|string|max:255',
|
|
|
|
|
- 'has_complement' => 'required|boolean',
|
|
|
|
|
- 'complement' => 'nullable|string|max:255',
|
|
|
|
|
- 'nickname' => 'nullable|string|max:255',
|
|
|
|
|
- 'instructions' => 'nullable|string',
|
|
|
|
|
- 'address_type' => ['required', Rule::in(['home', 'commercial', 'other'])],
|
|
|
|
|
- 'city' => 'required|string|max:255',
|
|
|
|
|
- 'state' => 'required|string|max:2',
|
|
|
|
|
- 'latitude' => 'sometimes|numeric|nullable',
|
|
|
|
|
- 'longitude' => 'sometimes|numeric|nullable',
|
|
|
|
|
-
|
|
|
|
|
- 'daily_price_8h' => "required|numeric|min:{$dailyPriceMin}|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' => 'required|file|image|mimes:jpg,jpeg,png,webp|max:5120',
|
|
|
|
|
- 'document_front' => 'required|file|image|mimes:jpg,jpeg,png,webp|max:10240',
|
|
|
|
|
- 'document_back' => 'required|file|image|mimes:jpg,jpeg,png,webp|max:10240',
|
|
|
|
|
|
|
+
|
|
|
|
|
+ 'services_types_ids' => 'sometimes|array',
|
|
|
|
|
+ 'services_types_ids.*' => 'integer|exists:service_types,id,deleted_at,NULL,is_active,1',
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
return $rules;
|
|
return $rules;
|