<?php

namespace App\Http\Controllers\Exports;

use App\Classes\Modules\Exports\Services\ExportsContainerPackingList;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Excel;

class ExportContainerPackingListController
{
    public function export(ExportsContainerPackingList $exportsContainerPackingList, Request $request) {
        $token = Auth::fromUser(User::find(1));
        $request->headers->set('Authorization', 'Bearer '.$token);
        $exportsContainerPackingList->setId($request->route('id'));
        return $exportsContainerPackingList->download('customer-container-packing-list.csv', Excel::CSV, ['Content-Type' => 'text/csv']);
    }
}
