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

45 lines
989 B
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\DailyChange;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithTitle;
class DailyChangesSheet 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-29 23:36:44 -05:00
2024-08-07 18:29:23 -05:00
public function headings(): array
{
return [
'Date',
2024-08-28 22:06:47 -05:00
'Portfolio ID',
2024-08-07 18:29:23 -05:00
'Total Market Value',
'Total Cost Basis',
2024-08-28 22:06:47 -05:00
'Total Gain',
2024-10-18 21:59:35 -05:00
'Total Dividends Earned',
2024-08-07 18:29:23 -05:00
'Realized Gains',
2025-01-28 17:14:49 -06:00
'Annotation',
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()
{
return $this->empty ? collect() : DailyChange::myDailyChanges()->withDailyPerformance()->get();
2024-08-07 18:29:23 -05:00
}
public function title(): string
{
return 'Daily Changes';
}
}