Files
investbrain/app/Exports/Sheets/TransactionsSheet.php
T

49 lines
1.0 KiB
PHP
Raw Normal View History

2024-08-07 18:29:23 -05:00
<?php
2025-01-28 17:33:54 -06:00
declare(strict_types=1);
2024-08-07 18:29:23 -05:00
namespace App\Exports\Sheets;
use App\Models\Transaction;
2024-08-28 22:06:47 -05:00
use Maatwebsite\Excel\Concerns\FromCollection;
2025-01-28 17:14:49 -06:00
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithTitle;
2024-08-07 18:29:23 -05:00
class TransactionsSheet implements FromCollection, WithHeadings, WithTitle
{
2024-08-29 23:36:44 -05:00
public function __construct(
public bool $empty = false
2025-01-28 17:14:49 -06:00
) {}
2024-08-30 20:22:28 -05:00
2024-08-07 18:29:23 -05:00
public function headings(): array
{
return [
2024-08-27 22:06:10 -05:00
'Transaction ID',
2024-08-07 18:29:23 -05:00
'Symbol',
2024-08-27 22:06:10 -05:00
'Portfolio ID',
'Transaction Type',
2024-08-07 18:29:23 -05:00
'Quantity',
'Cost Basis',
'Sale Price',
'Split',
2024-10-18 20:46:22 -05:00
'Reinvested Dividend',
2024-08-07 18:29:23 -05:00
'Date',
'Created',
2025-01-28 17:14:49 -06:00
'Updated',
2024-08-07 18:29:23 -05:00
];
}
/**
2025-01-28 17:14:49 -06:00
* @return \Illuminate\Support\Collection
*/
2024-08-07 18:29:23 -05:00
public function collection()
{
2024-08-29 23:36:44 -05:00
return $this->empty ? collect() : Transaction::myTransactions()->get();
2024-08-07 18:29:23 -05:00
}
public function title(): string
{
return 'Transactions';
}
}