2022-11-17 02:15:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Payment;
|
|
|
|
|
|
|
|
use App\Home\Blocks\Block;
|
|
|
|
use App\Member\Member;
|
|
|
|
|
|
|
|
class MemberPaymentBlock extends Block
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return array<string, string|int>
|
|
|
|
*/
|
|
|
|
public function data(): array
|
|
|
|
{
|
2022-12-13 23:11:32 +01:00
|
|
|
$amount = Payment::whereNeedsPayment()
|
|
|
|
->selectRaw('sum(subscription_children.amount) AS nr')
|
|
|
|
->join('subscriptions', 'subscriptions.id', 'payments.subscription_id')
|
|
|
|
->join('subscription_children', 'subscriptions.id', 'subscription_children.parent_id')
|
|
|
|
->first();
|
2022-11-17 02:15:29 +01:00
|
|
|
$members = Member::whereHasPendingPayment()->count();
|
|
|
|
|
|
|
|
return [
|
|
|
|
'members' => $members,
|
|
|
|
'total_members' => Member::count(),
|
2022-11-17 02:18:57 +01:00
|
|
|
'amount' => number_format((int) $amount->nr / 100, 2, ',', '.').' €',
|
2022-11-17 02:15:29 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function component(): string
|
|
|
|
{
|
|
|
|
return 'member-payment';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function title(): string
|
|
|
|
{
|
|
|
|
return 'Ausstehende Mitgliedsbeiträge';
|
|
|
|
}
|
|
|
|
}
|