This repository has been archived on 2024-05-20. You can view files and clone it, but cannot push or open issues or pull requests.
PriceyBotPanel/app/Traits/EnumOptions.php

27 lines
547 B
PHP

<?php
namespace App\Traits;
use Illuminate\Support\Str;
trait EnumOptions
{
public static function options(): array
{
$cases = static::cases();
$options = [];
foreach ($cases as $case) {
$label = $case->name;
if (Str::contains($label, '_')) {
$label = Str::replace('_', ' ', $label);
}
$options[] = [
'value' => $case->value,
'label' => Str::title($label),
];
}
return $options;
}
}