adrema/modules/Prevention/EfzPendingBlock.php

48 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2024-09-24 01:26:08 +02:00
<?php
namespace Modules\Prevention;
use Modules\Dashboard\Block;
use App\Member\Member;
use Illuminate\Database\Eloquent\Builder;
2024-10-13 21:00:47 +02:00
use Illuminate\Database\Eloquent\Collection;
2024-09-24 01:26:08 +02:00
class EfzPendingBlock extends Block
{
2024-10-13 21:00:47 +02:00
2024-09-24 01:26:08 +02:00
/**
2024-10-13 21:00:47 +02:00
* @var Collection<Member>
2024-09-24 01:26:08 +02:00
*/
2024-10-13 21:00:47 +02:00
public Collection $members;
public function mount(): void
2024-09-24 01:26:08 +02:00
{
2024-10-13 21:00:47 +02:00
$this->members = Member::where(function ($query) {
2024-09-24 01:26:08 +02:00
return $query->where('efz', '<=', now()->subYears(5)->endOfYear())
->orWhereNull('efz');
})
->whereCurrentGroup()
->orderByRaw('lastname, firstname')
2024-10-13 21:00:47 +02:00
->whereHas('memberships', fn ($builder) => $builder->isLeader()->active())
->get();
2024-09-24 01:26:08 +02:00
}
public function title(): string
{
return 'Ausstehende Führungszeugnisse';
}
public function render(): string
{
2024-10-13 21:00:47 +02:00
return <<<'HTML'
<div>
@foreach($members as $member)
<div class="flex mt-2 items-center leading-none text-gray-100">
<span class="grow">{{$member->fullname}}</span>
</div>
@endforeach
</div>
HTML;
2024-09-24 01:26:08 +02:00
}
}