Initial commit
This commit is contained in:
72
app/Exports/ProfileTransactionsExport.php
Normal file
72
app/Exports/ProfileTransactionsExport.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user