<?php

namespace App\Modules\HR\Employees\DTOs;

use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;

final readonly class EmployeeFileUploads
{
    public function __construct(
        public ?UploadedFile $photo = null,
        public ?UploadedFile $cv = null,
        public ?UploadedFile $nationalIdFront = null,
        public ?UploadedFile $nationalIdBack = null,
        public ?UploadedFile $passport = null,
        public ?UploadedFile $contract = null,
        public ?UploadedFile $certificate = null,
        public ?UploadedFile $residency = null,
        public ?UploadedFile $visa = null,
        public ?UploadedFile $workPermit = null,
        public ?string $passportExpiresAt = null,
        public ?string $contractExpiresAt = null,
        public ?string $nationalIdExpiresAt = null,
        public ?string $residencyExpiresAt = null,
        public ?string $visaExpiresAt = null,
        public ?string $workPermitExpiresAt = null,
    ) {}

    public static function fromRequest(Request $request): self
    {
        return new self(
            photo: $request->file('doc_photo'),
            cv: $request->file('doc_cv'),
            nationalIdFront: $request->file('doc_national_id_front'),
            nationalIdBack: $request->file('doc_national_id_back'),
            passport: $request->file('doc_passport'),
            contract: $request->file('doc_contract'),
            certificate: $request->file('doc_certificate'),
            residency: $request->file('doc_residency'),
            visa: $request->file('doc_visa'),
            workPermit: $request->file('doc_work_permit'),
            passportExpiresAt: $request->input('doc_passport_expires_at'),
            contractExpiresAt: $request->input('doc_contract_expires_at'),
            nationalIdExpiresAt: $request->input('doc_national_id_expires_at'),
            residencyExpiresAt: $request->input('doc_residency_expires_at'),
            visaExpiresAt: $request->input('doc_visa_expires_at'),
            workPermitExpiresAt: $request->input('doc_work_permit_expires_at'),
        );
    }
}
