streams() ->where('is_active', true) ->get(); $totalMonthlyIncome = $streams ->where('type', StreamTypeEnum::INCOME) ->sum(fn($stream) => $stream->getMonthlyEquivalent()); $totalMonthlyExpenses = $streams ->where('type', StreamTypeEnum::EXPENSE) ->sum(fn($stream) => $stream->getMonthlyEquivalent()); return [ 'total_streams' => $streams->count(), 'active_streams' => $streams->where('is_active', true)->count(), 'income_streams' => $streams->where('type', StreamTypeEnum::INCOME)->count(), 'expense_streams' => $streams->where('type', StreamTypeEnum::EXPENSE)->count(), 'monthly_income' => $totalMonthlyIncome, 'monthly_expenses' => $totalMonthlyExpenses, 'monthly_net' => $totalMonthlyIncome - $totalMonthlyExpenses, ]; } }