v7.0.0-beta.1 release
This commit is contained in:
commit
6595fd0eb5
3967 files changed
+1875383
No files matched your search
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Ecommerce\Enums;
|
||||
|
||||
/**
|
||||
* 쿠폰 발급 방법 Enum
|
||||
*/
|
||||
enum CouponIssueMethod: string
|
||||
{
|
||||
case DIRECT = 'direct'; // 직접발급
|
||||
case DOWNLOAD = 'download'; // 다운로드
|
||||
case AUTO = 'auto'; // 자동발급
|
||||
|
||||
/**
|
||||
* 다국어 라벨을 반환합니다.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function label(): string
|
||||
{
|
||||
return __($this->labelKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* 번역 키를 반환합니다.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function labelKey(): string
|
||||
{
|
||||
return 'sirsoft-ecommerce::enums.coupon_issue_method.'.$this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 배지 색상을 반환합니다.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function badgeColor(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::DIRECT => 'gray',
|
||||
self::DOWNLOAD => 'teal',
|
||||
self::AUTO => 'blue',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 모든 값 배열을 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
|
||||
/**
|
||||
* 프론트엔드용 옵션 배열을 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function toSelectOptions(): array
|
||||
{
|
||||
return array_map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
], self::cases());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user