Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Exports;
use Carbon\Carbon;
use HiEvents\DomainObjects\AffiliateDomainObject;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class AffiliatesExport implements FromCollection, WithHeadings, WithMapping, WithStyles
{
private LengthAwarePaginator $affiliates;
public function withData(LengthAwarePaginator $affiliates): AffiliatesExport
{
$this->affiliates = $affiliates;
return $this;
}
public function collection(): Collection
{
return collect($this->affiliates->items());
}
public function headings(): array
{
return [
__('ID'),
__('Name'),
__('Code'),
__('Email'),
__('Total Sales'),
__('Total Sales Gross'),
__('Status'),
__('Created At'),
__('Updated At'),
];
}
/**
* @param AffiliateDomainObject $affiliate
*/
public function map($affiliate): array
{
return [
$affiliate->getId(),
$affiliate->getName(),
$affiliate->getCode(),
$affiliate->getEmail(),
$affiliate->getTotalSales(),
$affiliate->getTotalSalesGross(),
$affiliate->getStatus(),
Carbon::parse($affiliate->getCreatedAt())->format('Y-m-d H:i:s'),
Carbon::parse($affiliate->getUpdatedAt())->format('Y-m-d H:i:s'),
];
}
public function styles(Worksheet $sheet): array
{
return [
1 => ['font' => ['bold' => true]],
];
}
}