adrema/app/Prevention/Enums/Prevention.php

54 lines
1.3 KiB
PHP
Raw Normal View History

2024-07-02 22:55:37 +02:00
<?php
namespace App\Prevention\Enums;
2024-07-22 20:27:55 +02:00
use App\Member\Member;
use Carbon\Carbon;
2024-07-24 22:26:38 +02:00
use Illuminate\Support\Collection;
2024-07-22 20:27:55 +02:00
2024-07-02 22:55:37 +02:00
enum Prevention
{
case EFZ;
case PS;
case MOREPS;
2024-07-18 13:57:52 +02:00
case VK;
2024-07-02 22:55:37 +02:00
public function text(): string
{
return match ($this) {
static::EFZ => 'erweitertes Führungszeugnis',
static::PS => 'Präventionsschulung Basis Plus',
static::MOREPS => 'Präventionsschulung (Auffrischung)',
2024-07-18 13:57:52 +02:00
static::VK => 'Verhaltenskodex',
2024-07-02 22:55:37 +02:00
};
}
2024-07-22 20:27:55 +02:00
public function tooltip(bool $value): string
{
return $this->text() . ' ' . ($value ? 'vorhanden' : 'nicht vorhanden');
}
public function letter(): string
{
return match ($this) {
static::EFZ => 'F',
static::PS => 'P',
static::MOREPS => 'A',
static::VK => 'V',
};
}
/**
* @param array<int, self> $preventions
2024-07-24 22:26:38 +02:00
* @return Collection<int, array{letter: string, value: bool, tooltip: string}>
2024-07-22 20:27:55 +02:00
*/
2024-07-24 22:26:38 +02:00
public static function items(array $preventions): Collection
2024-07-22 20:27:55 +02:00
{
return collect(static::cases())->map(fn ($case) => [
'letter' => $case->letter(),
'value' => !in_array($case, $preventions),
'tooltip' => $case->tooltip(!in_array($case, $preventions)),
]);
}
2024-07-02 22:55:37 +02:00
}