Files
finansePRO/app/Controllers/Investments.php
T
2026-07-06 20:16:00 +02:00

32 lines
929 B
PHP

<?php
namespace App\Controllers;
use App\Models\InstrumentModel;
class Investments extends BaseController
{
public function index()
{
$model = model(InstrumentModel::class);
$instruments = $model->withStats();
// Kafelki portfela = suma po instrumentach (spojne ze zrodlem prawdy w withStats).
$netInvested = 0.0;
$value = 0.0;
foreach ($instruments as $i) {
$netInvested += (float) $i['net_invested'];
$value += (float) $i['value'];
}
return view('investments/index', [
'title' => 'Pulpit inwestycji',
'instruments' => $instruments,
'net_invested' => round($netInvested, 2),
'value' => round($value, 2),
'profit' => round($value - $netInvested, 2),
'timeline' => $model->portfolioTimeline(),
]);
}
}