fix(enum): mengubah value jenis kelamin FEMALE menjadi 2 sebelumnya 0
-menambahkan method comment -menyesuaikan label UserStatus -menambahkan method icon UserStatus
This commit is contained in:
parent
5cba7e529a
commit
e79235ae86
@ -30,4 +30,9 @@ public static function values(): array
|
|||||||
{
|
{
|
||||||
return array_map(fn ($case) => $case->value, self::cases());
|
return array_map(fn ($case) => $case->value, self::cases());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function comment(): string
|
||||||
|
{
|
||||||
|
return implode(', ', array_map(fn ($case) => "{$case->value}: {$case->label()}", self::cases()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
enum Gender: int
|
enum Gender: int
|
||||||
{
|
{
|
||||||
case MALE = 1;
|
case MALE = 1;
|
||||||
case FEMALE = 0;
|
case FEMALE = 2;
|
||||||
|
|
||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
@ -27,4 +27,9 @@ public static function values(): array
|
|||||||
{
|
{
|
||||||
return array_map(fn ($case) => $case->value, self::cases());
|
return array_map(fn ($case) => $case->value, self::cases());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function comment(): string
|
||||||
|
{
|
||||||
|
return implode(', ', array_map(fn ($case) => "{$case->value}: {$case->label()}", self::cases()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,9 +11,9 @@ enum UserStatus: int
|
|||||||
public function label(): string
|
public function label(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::ACTIVE => 'Active',
|
self::ACTIVE => 'Aktif',
|
||||||
self::INACTIVE => 'Inactive',
|
self::INACTIVE => 'Tidak Aktif',
|
||||||
self::SUSPENDED => 'Suspended',
|
self::SUSPENDED => 'Suspend',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,8 +26,22 @@ public function color(): string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function icon(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::ACTIVE => 'check-circle',
|
||||||
|
self::INACTIVE => 'x-circle',
|
||||||
|
self::SUSPENDED => 'ban',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static function values(): array
|
public static function values(): array
|
||||||
{
|
{
|
||||||
return array_map(fn ($case) => $case->value, self::cases());
|
return array_map(fn ($case) => $case->value, self::cases());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function comment(): string
|
||||||
|
{
|
||||||
|
return implode(', ', array_map(fn ($case) => "{$case->value}: {$case->label()}", self::cases()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user