ldc-nature-and-respect/app/Enums/Recipes/CookingEnum.php
2023-04-18 10:49:39 +02:00

48 lines
1 KiB
PHP

<?php
namespace App\Enums\Recipes;
enum CookingEnum : int
{
case cook = 1;
case grill = 2;
public function label(): string
{
return static::getLabel($this);
}
public function image(): string
{
return static::getImage($this);
}
public static function getLabel(self $value): string
{
return match ($value) {
self::cook => __('Cook'),
self::grill => __('Grill'),
};
}
public static function getImage(self $value): string
{
return match ($value) {
self::cook => "cook.png",
self::grill => "grill.png",
};
}
public static function getData(): array
{
$arrayEnum = [];
foreach (self::cases() as $key => $value) {
$arrayEnum = array_merge($arrayEnum, [[
"value" => $value->value,
"label" => $value->label(),
"image" => $value->image()
]]);
}
return $arrayEnum;
}
}