refactor(enum): menyelarasikan semua enum agar sama

This commit is contained in:
Yoga Pangestu 2025-12-08 13:46:22 +07:00
parent d27195a053
commit 67fe31439c
18 changed files with 84 additions and 32 deletions

View File

@ -13,7 +13,7 @@ enum ArticleStatus: int
case DRAFT = 2;
case ARCHIVED = 3;
public function label()
public function label(): string
{
return match ($this) {
self::PUBLISHED => 'Publish',
@ -22,7 +22,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::PUBLISHED => 'emerald',

View File

@ -2,13 +2,27 @@
namespace App\Enums;
use App\Traits\WithCommentEnum;
use App\Traits\WithValueEnum;
enum AuditStockStatus: string
{
use WithCommentEnum, WithValueEnum;
case INCREASED = 'Menambah';
case DECREASED = 'Mengurangi';
case UPDATED = 'Mengubah';
public function color()
public function label(): string
{
return match ($this) {
self::INCREASED => 'Menambah',
self::DECREASED => 'Mengurangi',
self::UPDATED => 'Mengubah',
};
}
public function color(): string
{
return match ($this) {
self::INCREASED => 'emerald',

View File

@ -14,7 +14,7 @@ enum Concentration: int
case EAU_DE_COLOGNE = 3;
case EAU_DE_TOILETTE = 4;
public function label()
public function label(): string
{
return match ($this) {
self::EXTRAIT_DE_PERFUME => 'Extrait de Parfum',
@ -24,7 +24,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::EXTRAIT_DE_PERFUME => 'emerald',

View File

@ -17,7 +17,7 @@ enum Day: int
case FRIDAY = 6;
case SATURDAY = 7;
public function label()
public function label(): string
{
return match ($this) {
self::SUNDAY => 'Minggu',
@ -29,4 +29,17 @@ public function label()
self::SATURDAY => 'Sabtu',
};
}
public function color(): string
{
return match ($this) {
self::SUNDAY => 'red',
self::MONDAY => 'blue',
self::TUESDAY => 'green',
self::WEDNESDAY => 'yellow',
self::THURSDAY => 'orange',
self::FRIDAY => 'purple',
self::SATURDAY => 'pink',
};
}
}

View File

@ -13,7 +13,7 @@ enum EmploymentStatus: int
case CONTRACT = 2;
case INTERN = 3;
public function label()
public function label(): string
{
return match ($this) {
self::PERMANENT => 'Permanen',
@ -22,7 +22,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::PERMANENT => 'emerald',

View File

@ -13,7 +13,7 @@ enum ExpenseType: int
case PURCHASE = 2;
case SALARY = 3;
public function label()
public function label(): string
{
return match ($this) {
self::OPERATIONAL => 'Operasional',
@ -22,7 +22,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::OPERATIONAL => 'emerald',

View File

@ -11,7 +11,7 @@ enum Gender: int
case MALE = 1;
case FEMALE = 2;
public function label()
public function label(): string
{
return match ($this) {
self::MALE => 'Laki-laki',
@ -19,7 +19,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::MALE => 'blue',

View File

@ -12,7 +12,7 @@ enum IsActive: int
case ACTIVE = 1;
case INACTIVE = 2;
public function label()
public function label(): string
{
return match ($this) {
self::ACTIVE => 'Aktif',
@ -20,7 +20,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::ACTIVE => 'emerald',

View File

@ -12,7 +12,7 @@ enum IsPaid: int
case PAID = 1;
case NOT_PAID = 2;
public function label()
public function label(): string
{
return match ($this) {
self::PAID => 'Dibayar',
@ -20,7 +20,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::PAID => 'emerald',

View File

@ -12,7 +12,7 @@ enum IsShow: int
case SHOW = 1;
case HIDDEN = 2;
public function label()
public function label(): string
{
return match ($this) {
self::SHOW => 'Ditampilkan',
@ -20,7 +20,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::SHOW => 'emerald',

View File

@ -13,7 +13,7 @@ enum OutletStatus: int
case UNDER_CONSTRUCTION = 2;
case TERMINATED = 3;
public function label()
public function label(): string
{
return match ($this) {
self::OPERATIONAL => 'Operasional',
@ -22,7 +22,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::OPERATIONAL => 'emerald',

View File

@ -12,7 +12,7 @@ enum PointRecordType: int
case TIER = 1;
case REWARD = 2;
public function label()
public function label(): string
{
return match ($this) {
self::TIER => 'Tier',
@ -20,7 +20,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::TIER => 'emerald',

View File

@ -22,7 +22,7 @@ public function label(): string
};
}
public function color()
public function color(): string
{
return match ($this) {
self::PENDING => 'gray',

View File

@ -12,7 +12,7 @@ enum SalaryAdjustmentType: int
case BONUS = 1;
case DEDUCTION = 2;
public function label()
public function label(): string
{
return match ($this) {
self::BONUS => 'Bonus',
@ -20,7 +20,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::BONUS => 'emerald',

View File

@ -14,7 +14,7 @@ enum StockOpnameStatus: int
case PENDING_APPROVAL = 3;
case COMPLETED = 4;
public function label()
public function label(): string
{
return match ($this) {
self::DRAFT => 'Draft',
@ -24,7 +24,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::DRAFT => 'yellow',

View File

@ -2,11 +2,12 @@
namespace App\Enums;
use App\Traits\WithCommentEnum;
use App\Traits\WithValueEnum;
enum UserRole: string
{
use WithValueEnum;
use WithCommentEnum, WithValueEnum;
case Developer = 'Developer';
case Owner = 'Owner';
@ -14,4 +15,28 @@ enum UserRole: string
case Admin = 'Admin';
case Partner = 'Partner';
case Customer = 'Customer';
public function label(): string
{
return match ($this) {
self::Developer => 'Developer',
self::Owner => 'Owner',
self::Leader => 'Leader',
self::Admin => 'Admin',
self::Partner => 'Partner',
self::Customer => 'Customer',
};
}
public function color(): string
{
return match ($this) {
self::Developer => 'purple',
self::Owner => 'emerald',
self::Leader => 'blue',
self::Admin => 'orange',
self::Partner => 'cyan',
self::Customer => 'gray',
};
}
}

View File

@ -12,7 +12,7 @@ enum UserStatus: int
case ACTIVE = 1;
case INACTIVE = 2;
public function label()
public function label(): string
{
return match ($this) {
self::ACTIVE => 'Aktif',
@ -20,7 +20,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::ACTIVE => 'emerald',

View File

@ -12,7 +12,7 @@ enum VoucherType: int
case FIXED = 1;
case PERCENTAGE = 2;
public function label()
public function label(): string
{
return match ($this) {
self::FIXED => 'Nominal',
@ -20,7 +20,7 @@ public function label()
};
}
public function color()
public function color(): string
{
return match ($this) {
self::FIXED => 'blue',