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

50 lines
1.0 KiB
PHP
Raw Normal View History

2024-08-07 18:29:23 -05:00
<?php
namespace App\Exports\Sheets;
use App\Models\Transaction;
use Maatwebsite\Excel\Concerns\WithTitle;
2024-08-28 22:06:47 -05:00
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\FromCollection;
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
) { }
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',
2024-08-28 22:06:47 -05:00
'Updated'
2024-08-07 18:29:23 -05:00
];
}
/**
* @return \Illuminate\Support\Collection
*/
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
}
/**
* @return string
*/
public function title(): string
{
return 'Transactions';
}
}