49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Illuminate\Support\Collection;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
|
|
|
class CurrentPriceExport implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping
|
|
{
|
|
/**
|
|
* @param Collection<int, array{supplier: ?string, producer: ?string, mainGroup: string, subGroup1: string, subGroup2: string, name: string, price: ?float}> $rows
|
|
*/
|
|
public function __construct(private Collection $rows) {}
|
|
|
|
public function collection(): Collection
|
|
{
|
|
return $this->rows;
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'Beszállító',
|
|
'Gyártó',
|
|
'Termék Főcsoport',
|
|
'Termék alcsoport 1',
|
|
'Termék alcsoport 2',
|
|
'Termék megnevezése',
|
|
'Aktuális ár',
|
|
];
|
|
}
|
|
|
|
public function map($row): array
|
|
{
|
|
return [
|
|
$row['supplier'] ?? '',
|
|
$row['producer'] ?? '',
|
|
$row['mainGroup'] ?? '',
|
|
$row['subGroup1'] ?? '',
|
|
$row['subGroup2'] ?? '',
|
|
$row['name'],
|
|
$row['price'],
|
|
];
|
|
}
|
|
}
|