45 lines
979 B
PHP
45 lines
979 B
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
use Dcat\Admin\Admin;
|
|
|
|
enum OfflineOrderStatus: int {
|
|
case Pending = 0;
|
|
case Paid = 1;
|
|
case Revoked = 10;
|
|
|
|
public function dot()
|
|
{
|
|
$color = $this->color();
|
|
|
|
$background = Admin::color()->get($color, $color);
|
|
|
|
return '<i class="fa fa-circle" style="font-size: 13px;color: '.$background.'"></i> '.$this->text() ?? 'Unknown';
|
|
}
|
|
|
|
public function text()
|
|
{
|
|
return static::options()[$this->value] ?? 'Unknown';
|
|
}
|
|
|
|
public function color()
|
|
{
|
|
return match ($this) {
|
|
static::Pending => 'primary',
|
|
static::Paid => 'success',
|
|
static::Revoked => '#b3b9bf',
|
|
default => 'warning',
|
|
};
|
|
}
|
|
|
|
public static function options(): array
|
|
{
|
|
return [
|
|
self::Pending->value => '待付款',
|
|
self::Paid->value => '已付款',
|
|
self::Revoked->value => '已取消',
|
|
];
|
|
}
|
|
}
|