Create Enum for Invoice type codes and build a translatable Trait.
This commit is contained in:
20
app/Enum/hasTranslatable.php
Normal file
20
app/Enum/hasTranslatable.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enum;
|
||||
|
||||
trait hasTranslatable
|
||||
{
|
||||
public static function options(): array
|
||||
{
|
||||
$options = [];
|
||||
foreach (self::cases() as $value) {
|
||||
$options[$value->value] = __('enum.' . $value->name);
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public static function label($value)
|
||||
{
|
||||
return self::options()[$value];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user