<?php

namespace App\Classes\Modules\Reports\ControllersLogic;

use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Models\User;
use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Classes\Modules\Reports\ControllersLogic\ExportExcelLogic;
use App\Classes\Modules\PackingLists\Processors\FetchPackingListProcessor;

class CustomcClearanceLogic extends AbstractControllerLogic
{
    private $excelExportLogic;
    private $listsPackingListProcessor;

    public function __construct(FetchPackingListProcessor $listsPackingListProcessor){
        $this->listsPackingListProcessor = $listsPackingListProcessor;
    }

    protected function notification():array {
        return [];
    }

    public function logic(Request $request) : JsonResponse
    {
        $params = $request->all();
        $packingLists = $this->listsPackingListProcessor->execute($params);
        $excelExportLogic = new ExportExcelLogic(collect($packingLists));
        $this->excelExportLogic = $excelExportLogic;

        return response()->json(['success' => true]);
    }

    public function getExcelCollection(){
        return $this->excelExportLogic;
    }
}
