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(), ]); } }