adrema/modules/Invoice/MemberPaymentBlock.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2024-09-24 01:26:08 +02:00
<?php
namespace Modules\Invoice;
use Modules\Dashboard\Block;
use App\Invoice\Models\InvoicePosition;
use App\Member\Member;
class MemberPaymentBlock extends Block
{
2024-10-13 21:00:47 +02:00
public string $amount = '';
public int $members = 0;
public int $totalMembers = 0;
public function mount(): void
2024-09-24 01:26:08 +02:00
{
$amount = InvoicePosition::whereHas('invoice', fn ($query) => $query->whereNeedsPayment())
->selectRaw('sum(price) AS price')
->first();
2024-10-13 21:00:47 +02:00
$this->amount = number_format((int) $amount->price / 100, 2, ',', '.') . ' €';
$this->members = Member::whereHasPendingPayment()->count();
$this->totalMembers = Member::count();
2024-09-24 01:26:08 +02:00
}
public function title(): string
{
return 'Ausstehende Mitgliedsbeiträge';
}
public function render(): string
{
2024-10-13 21:00:47 +02:00
return <<<'HTML'
<div>
<div class="text-gray-100">
<span class="text-xl mr-1 font-semibold">{{$amount}}</span>
<span class="text-sm">von {{$members}} / {{$totalMembers}} Mitgliedern</span>
</div>
</div>
HTML;
2024-09-24 01:26:08 +02:00
}
}