selectRaw('sum(subscriptions.amount) AS a')->join('subscriptions', 'subscriptions.id', 'payments.subscription_id')->first(); $members = Member::whereHasPendingPayment()->count(); return [ 'data' => [ 'payments' => [ 'users' => $members, 'all_users' => Member::count(), 'amount' => number_format($amount->a / 100, 2, ',', '.').' €', ], 'groups' => app(GroupQuery::class)->execute()->getResult(), 'ending_tries' => MemberTriesResource::collection(Member::endingTries()->get()), ], ]; } }