6
0
Fork 0
jiqu-library-server/app/Enums/DrawActivityStatus.php

42 lines
1.1 KiB
PHP

<?php
namespace App\Enums;
use Dcat\Admin\Admin;
enum DrawActivityStatus: int {
case Created = 0; // 已创建
case Publishing = 1; // 发布中
case Unstart = 2; // 未开始
case Running = 3; // 进行中
case Closed = 4; // 已结束
public function label()
{
$color = match ($this) {
static::Created => 'primary',
static::Publishing => 'blue',
static::Unstart => 'danger',
static::Running => 'success',
static::Closed => 'gray',
};
$background = Admin::color()->get($color, $color);
$name = static::options()[$this->value] ?? 'Unknown';
return "<span class='label' style='background: $background;'>{$name}</span>";
}
public static function options()
{
return [
static::Created->value => '已创建',
static::Publishing->value => '发布中',
static::Unstart->value => '未开始',
static::Running->value => '进行中',
static::Closed->value => '已结束',
];
}
}