<?php

namespace App\Http\Controllers\Imports;

use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\Modules\Imports\Services\ImportsDebtor;
use  App\Classes\General\ExcelHandel;

use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Maatwebsite\Excel\Facades\Excel;
use Maatwebsite\Excel\Excel as ExcelFileTypes;

class ImportUpdateDebtorController
{
    /**
     * @param Request $request
     * @return array
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function import(Request $request) {
        $object = new DocumentObject('', $request->input('files'), '', ApprovalStatus::APPROVED, 'imports');
        Excel::import(new ImportsDebtor(), 'documents/'.json_decode($object->getFiles()[0])->file_info->original->file);
        return [];
    }
}
