{{-- ─── Summary stats ───────────────────────────────────────────────────────── --}} @php $totalInvested = $portfolios->sum(fn($p) => ($p->shares ?? $p->quantity ?? 0) * ($p->buy_price ?? 0)); $totalCurrent = $portfolios->sum(fn($p) => ($p->shares ?? $p->quantity ?? 0) * ($p->current_price ?? $p->buy_price ?? 0)); $totalPnl = $totalCurrent - $totalInvested; $totalPnlPct = $totalInvested > 0 ? ($totalPnl / $totalInvested) * 100 : 0; @endphp
{{-- ─── Holdings table ─────────────────────────────────────────────────────── --}} @if($portfolios->isEmpty()) @else
@foreach($portfolios as $holding) @php $shares = $holding->shares ?? $holding->quantity ?? 0; $buyPrice = $holding->buy_price ?? 0; $curPrice = $holding->current_price ?? $buyPrice; $value = $shares * $curPrice; $pnl = $shares * ($curPrice - $buyPrice); $pnlPct = $buyPrice > 0 ? (($curPrice - $buyPrice) / $buyPrice) * 100 : 0; @endphp @endforeach
Asset Shares Value P&L
{{ strtoupper(substr($holding->stock->symbol ?? 'S', 0, 2)) }}

{{ $holding->stock->symbol ?? 'N/A' }}

{{ $holding->stock->name ?? '' }}

{{ number_format($shares, 4) }} ${{ number_format($value, 2) }}

{{ $pnl >= 0 ? '+' : '' }}${{ number_format($pnl, 2) }}

{{ $pnlPct >= 0 ? '+' : '' }}{{ number_format($pnlPct, 2) }}%

@if($portfolios->hasPages())
{{ $portfolios->links() }}
@endif @endif