adrema/app/Invoice/MemberPaymentBlock.php

38 lines
889 B
PHP
Raw Permalink Normal View History

2022-11-17 02:15:29 +01:00
<?php
2023-12-17 01:49:12 +01:00
namespace App\Invoice;
2022-11-17 02:15:29 +01:00
2023-04-29 21:30:41 +02:00
use App\Dashboard\Blocks\Block;
2023-12-17 01:49:12 +01:00
use App\Invoice\Models\InvoicePosition;
2022-11-17 02:15:29 +01:00
use App\Member\Member;
class MemberPaymentBlock extends Block
{
/**
* @return array<string, string|int>
*/
public function data(): array
{
2023-12-17 01:49:12 +01:00
$amount = InvoicePosition::whereHas('invoice', fn ($query) => $query->whereNeedsPayment())
->selectRaw('sum(price) AS price')
2022-12-13 23:11:32 +01:00
->first();
2022-11-17 02:15:29 +01:00
$members = Member::whereHasPendingPayment()->count();
return [
'members' => $members,
'total_members' => Member::count(),
2023-12-17 01:49:12 +01:00
'amount' => number_format((int) $amount->price / 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';
}
}