adrema/app/Invoice/Enums/InvoiceStatus.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2023-12-13 00:35:39 +01:00
<?php
namespace App\Invoice\Enums;
use Illuminate\Support\Collection;
enum InvoiceStatus: string
{
case NEW = 'Neu';
case SENT = 'Rechnung gestellt';
case PAID = 'Rechnung beglichen';
/**
* @return Collection<int, string>
*/
public static function values(): Collection
{
return collect(static::cases())->map(fn ($case) => $case->value);
}
2023-12-16 20:35:28 +01:00
2024-05-14 01:29:39 +02:00
/**
* @return Collection<int, string>
*/
public static function defaultVisibleValues(): Collection
{
return collect(static::cases())->filter(fn ($value) => $value->defaultVisible())->map(fn ($case) => $case->value);
}
public function defaultVisible(): bool
{
return match ($this) {
static::NEW => true,
static::SENT => true,
static::PAID => false
};
}
2023-12-16 20:35:28 +01:00
/**
* @return array<int, array{id: string, name: string}>
*/
public static function forSelect(): array
{
return array_map(fn ($case) => ['id' => $case->value, 'name' => $case->value], static::cases());
}
2023-12-13 00:35:39 +01:00
}