32 lines
929 B
PHP
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(),
|
|
]);
|
|
}
|
|
}
|