selectRaw('sum(subscriptions.amount) AS a')->join('subscriptions', 'subscriptions.id', 'payments.subscription_id')->first()->a; $members = Member::whereHasPendingPayment()->count(); return [ 'data' => [ 'payments' => [ 'users' => $members, 'all_users' => Member::count(), 'amount' => number_format($amount / 100, 2, ',', '.').' €' ] ] ]; } }