adrema/app/Efz/EfzPendingBlock.php

45 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2022-11-17 02:15:29 +01:00
<?php
namespace App\Efz;
2023-04-29 21:30:41 +02:00
use App\Dashboard\Blocks\Block;
2022-11-17 02:15:29 +01:00
use App\Member\Member;
use Illuminate\Database\Eloquent\Builder;
class EfzPendingBlock extends Block
{
/**
* @return Builder<Member>
*/
public function query(): Builder
{
return Member::where(function ($query) {
return $query->where('efz', '<=', now()->subYears(5)->endOfYear())
->orWhereNull('efz');
})
->whereCurrentGroup()
2022-11-17 02:15:29 +01:00
->orderByRaw('lastname, firstname')
->whereHas('memberships', fn ($builder) => $builder->isLeader()->active());
2022-11-17 02:15:29 +01:00
}
/**
2022-11-17 02:18:57 +01:00
* @return array{members: array<int, string>}
2022-11-17 02:15:29 +01:00
*/
public function data(): array
{
return [
'members' => $this->query()->get()->map(fn ($member) => $member->fullname)->toArray(),
];
}
public function component(): string
{
return 'efz-pending';
}
public function title(): string
{
return 'Ausstehende Führungszeugnisse';
}
}