adrema/modules/Member/TestersBlock.php

47 lines
1.3 KiB
PHP
Raw Normal View History

2024-09-24 01:26:08 +02:00
<?php
namespace Modules\Member;
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 TestersBlock extends Block
{
2024-10-13 21:00:47 +02:00
private $months = 8;
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::whereHas('memberships', fn ($q) => $q->isTrying())
->with('memberships', fn ($q) => $q->isTrying())
->get();
2024-09-24 01:26:08 +02:00
}
public function title(): string
{
return 'Endende Schhnupperzeiten';
}
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>
<span class="mr-2 text-sm tex-gray-600">{{ $member->memberships->first()->from->addWeeks($this->months)->format('d.m.Y') }}</span>
<span class="text-xs tex-gray-600">{{ $member->memberships->first()->from->addWeeks($this->months)->diffForHumans() }}</span>
</div>
@endforeach
</div>
HTML;
2024-09-24 01:26:08 +02:00
}
}