Files
ephub/src/Enum/ResourceType.php
T

67 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Enum;
/**
* The kinds of thing that can be booked.
*
* **This enum is the extension point.** The dashboard builds one tile per case, the board route
* accepts one backing value per case, and the floor plan and the admin screen render every kind
* the same way. Adding a third bookable kind is therefore: a case here.
* Nothing else needs editing — in particular no template lists the kinds by hand.
*
* The backing value is both what is persisted in `resource.type` and what appears in a URL, so
* there is no slug mapping to keep in sync. The label, plural and description are the only
* things here anyone sees, which is why they are the only German ones.
*/
enum ResourceType: string
{
case DESK = 'desk';
case PARKING = 'parking';
public function label(): string
{
return match ($this) {
self::DESK => 'Schreibtisch',
self::PARKING => 'Parkplatz',
};
}
public function plural(): string
{
return match ($this) {
self::DESK => 'Schreibtische',
self::PARKING => 'Parkplätze',
};
}
public function description(): string
{
return match ($this) {
self::DESK => 'Einen Platz im Büro reservieren.',
self::PARKING => 'Einen Stellplatz reservieren.',
};
}
/**
* What a ResourceGroup of this kind is called: an office has rooms, a car park has areas.
*/
public function groupLabel(): string
{
return match ($this) {
self::DESK => 'Raum',
self::PARKING => 'Bereich',
};
}
public function icon(): string
{
return match ($this) {
self::DESK => 'lucide:armchair',
self::PARKING => 'lucide:car',
};
}
}