4
0
Fork 0
dcat-admin-order/src/Enums/OrderScene.php

52 lines
1020 B
PHP

<?php
namespace Peidikeji\Order\Enums;
enum OrderScene: int
{
case Online = 0;
case Merchant = 1;
case Scan = 2;
public static function options()
{
return [
self::Online->value => '线上商城',
self::Merchant->value => '线下门店',
self::Scan->value => '扫码付款',
];
}
public function text()
{
return data_get(self::options(), $this->value);
}
public function color()
{
return match ($this) {
static::Online => 'primary',
static::Merchant => 'warning',
static::Scan => 'success',
};
}
public function label()
{
$color = $this->color();
$name = $this->text();
return "<span class='label bg-${color}'>{$name}</span>";
}
public function dot()
{
$color = $this->color();
$name = $this->text();
return "<i class='fa fa-circle text-$color'>&nbsp;&nbsp;{$name}</span>";
}
}