Create Enum for Invoice type codes and build a translatable Trait.
This commit is contained in:
18
app/Enum/InvoiceTypeCode.php
Normal file
18
app/Enum/InvoiceTypeCode.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enum;
|
||||
|
||||
enum InvoiceTypeCode: string
|
||||
{
|
||||
use hasTranslatable;
|
||||
|
||||
case PARTIAL_INVOICE = '326';
|
||||
case COMMERCIAL_INVOICE = '380';
|
||||
case CREDIT_NOTE = '381';
|
||||
case CORRECTED_INVOICE = '384';
|
||||
case SELF_BILLED_INVOICE = '389';
|
||||
case PARTIAL_CONSTRUCTION_INVOICE = '875';
|
||||
case PARTIAL_FINAL_CONSTRUCTION_INVOICE = '876';
|
||||
case FINAL_CONSTRUCTION_INVOICE = '877';
|
||||
|
||||
}
|
||||
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