Files
investbrain/app/Exports/Sheets/DailyChangesSheet.php
T
hackerESQ 97b13063d9 wip
2025-08-11 19:58:17 -05:00

44 lines
963 B
PHP

<?php
declare(strict_types=1);
namespace App\Exports\Sheets;
use App\Models\DailyChange;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithTitle;
class DailyChangesSheet implements FromCollection, WithHeadings, WithTitle
{
public function __construct(
public bool $empty = false
) {}
public function headings(): array
{
return [
'Date',
'Portfolio ID',
'Total Market Value',
'Total Cost Basis',
'Realized Gains',
'Total Dividends Earned',
'Annotation',
];
}
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return $this->empty ? collect() : DailyChange::myDailyChanges()->withDailyPerformance()->get();
}
public function title(): string
{
return 'Daily Changes';
}
}