Files
timebank-cc-public/app/Exports/ProfileTransactionsExport.php
Ronald Huynen 2547717edb Initial commit
2026-03-23 21:37:59 +01:00

73 lines
1.9 KiB
PHP

<?php
namespace App\Exports;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithTitle;
class ProfileTransactionsExport implements FromCollection, WithTitle, WithHeadings, WithMapping
{
use Exportable;
protected $data;
public function __construct(Collection $data)
{
$this->data = $data;
}
public function collection()
{
return $this->data;
}
public function headings(): array
{
return [
__('Nr.'),
__('Date'),
__('Amount'),
__('Amount in minutes'),
__('Amount in hours'),
__('Debit/Credit'),
__('Account nr.'),
__('Account name'),
__('Counter acc. nr.'),
__('Counter acc. name'),
__('Relation name'),
__('Relation full name'),
__('Type'),
__('Description'),
];
}
public function map($transaction): array
{
return [
$transaction['trans_id'],
$transaction['datetime'],
tbFormat($transaction['amount']),
$transaction['amount'],
round($transaction['amount'] / 60, 4),
__($transaction['c/d']),
$transaction['account_id'],
__(ucfirst(strtolower($transaction['account_name']))),
$transaction['account_counter_id'],
__(ucfirst(strtolower($transaction['account_counter_name']))),
$transaction['relation'],
$transaction['relation_full_name'],
__(ucfirst(strtolower($transaction['type']))),
$transaction['description'],
];
}
public function title(): string
{
return __('Transactions');
}
}