<?php

namespace App\Http\Controllers\Delivery;


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

class ExportDeliveryOrdersToExcelController
{

    /**
     * ExportCustomersToExcelController constructor.
     * @param Request $request
     */
    public function __construct(Request $request)
    {
        $token = Auth::fromUser(User::find(1));
        $request->headers->set('Authorization', 'Bearer '.$token);
    }

    public function lineClear(Request $request){
        $exportsTransactions = new ExportsMultipleDeliveryOrders($request);
        $response = $exportsTransactions->download('line-clear-export.xlsx', Excel::XLSX, ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']);
        ob_end_clean();
        return $response;
    }

}