49 lines
1.0 KiB
PHP
49 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Exports\Sheets;
|
|
|
|
use App\Models\Transaction;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
|
|
class TransactionsSheet implements FromCollection, WithHeadings, WithTitle
|
|
{
|
|
public function __construct(
|
|
public bool $empty = false
|
|
) {}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'Transaction ID',
|
|
'Symbol',
|
|
'Portfolio ID',
|
|
'Transaction Type',
|
|
'Quantity',
|
|
'Cost Basis',
|
|
'Sale Price',
|
|
'Split',
|
|
'Reinvested Dividend',
|
|
'Date',
|
|
'Created',
|
|
'Updated',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Support\Collection
|
|
*/
|
|
public function collection()
|
|
{
|
|
return $this->empty ? collect() : Transaction::myTransactions()->get();
|
|
}
|
|
|
|
public function title(): string
|
|
{
|
|
return 'Transactions';
|
|
}
|
|
}
|