<?php

namespace App\Http\Requests\Quote;

use Illuminate\Foundation\Http\FormRequest;

class QuoteRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'social_reason' => 'required',
            'nit' => 'nullable',
            'address' => 'nullable',
            'phone' => 'required',
            'landline' => 'nullable',
            'percentage_initial_fee' => 'nullable',


            'email' => 'nullable|email',
            'workplace' => 'nullable',
            'expiration_date' => 'nullable',
            'creation_date' => 'nullable',
            'date_listing' => 'nullable',
            'observations' => 'nullable',

            'payment_method' => 'required',
            'contract_signing_date' => 'nullable',

            'amount' => 'required|numeric',
            'initial_fee' => 'required|numeric',
            'balance' => 'required|numeric',
            'differs_initial_fee' => 'nullable|array',
            'differs_initial_fee.*.date' => 'nullable',
            'differs_initial_fee.*.amount' => 'nullable|numeric',

            'differs_balance' => 'nullable|array',
            'differs_balance.*.date' => 'nullable',
            'differs_balance.*.amount' => 'nullable|numeric',

            'opportunity_id' => 'required',
            'customer_id' => 'required',

            'properties' => 'required|array',
            'properties.*.property_id' => 'required',
            'properties.*.price' => 'required',
            'properties.*.price_it' => 'required',
            'properties.*.price_contrato' => 'required',
        ];
    }
}
