<?php

namespace App\Http\Requests\Tenant;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

/**
 * Class DocumentRequest
 *
 * @package App\Http\Requests\Tenant
 * @mixin FormRequest
 */
class DocumentRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        $id = $this->input('id');
        return [
            'customer_id' => [
                'required',
            ],
            'establishment_id' => [
                'required',
            ],
            'series' => [
                'required',
            ],
            'date_of_issue' => [
                'required',
            ],
            'note.note_credit_type_id' => [
                'required_if:document_type_id, "07"',
            ],
            'note.note_debit_type_id' => [
                'required_if:document_type_id, "08"',
            ],
            'note.note_description' => [
                'required_if:document_type_id,"07", "08"',
            ],
            'exchange_rate_sale' => [
                'required',
                'numeric',
                'min:0.01'
            ],
        ];
    }
}
