adrema/app/Invoice/BillKind.php

32 lines
744 B
PHP
Raw Normal View History

2021-04-11 18:17:40 +02:00
<?php
2023-04-18 22:08:45 +02:00
namespace App\Invoice;
2021-04-11 18:17:40 +02:00
2022-12-06 23:11:57 +01:00
enum BillKind: string
2021-04-11 18:17:40 +02:00
{
2022-12-06 23:11:57 +01:00
case EMAIL = 'E-Mail';
case POST = 'Post';
/**
* @return array<string, string>
*/
public static function values(): array
{
return collect(static::cases())->map(fn ($case) => $case->value)->toArray();
}
/**
* @return array<int, array{name: string, id: string}>
*/
public static function forSelect(): array
{
return collect(static::cases())
->map(fn ($case) => ['id' => $case->value, 'name' => $case->value])
->toArray();
}
2022-08-12 22:07:59 +02:00
2022-12-06 23:11:57 +01:00
public static function fromValue(string $value): self
{
return collect(static::cases())->firstOrFail(fn ($case) => $case->value === $value);
}
2021-04-11 18:17:40 +02:00
}