File: D:/HostingSpaces/farmfun/reserveren.farmfun.be/app/Komma/Export/Exports/OrdersExport.php
<?php
namespace App\Komma\Export\Exports;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnWidths;
use Maatwebsite\Excel\Concerns\WithHeadings;
class OrdersExport implements FromView, WithHeadings, ShouldAutoSize, WithColumnWidths
{
private Collection $results;
public function __construct(Collection $results) {
$this->results = $results;
}
public function view(): View
{
return view('excel.export_orders', [
'attributes' => $this->headings(),
'results' => $this->results,
]);
}
public function headings(): array
{
return ['order_number', 'company_name', 'company_vat_number', 'first_name', 'last_name', 'location_id', 'location_name', 'product_id', 'product_name', 'quantity', 'created_at', 'event_date', 'remarks', 'price_each_unit', 'price_each_unit_excluding_vat', 'price_start_up', 'price_start_up_excluding_vat'];
}
public function columnWidths(): array
{
return [
'A' => 30,
'B' => 50,
'J' => 100,
];
}
}