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

52 lines
1010 B
PHP

<?php
namespace Peidikeji\Order\Enums;
enum ShipWay: string
{
case None = 'none';
case Express = 'express';
case Pick = 'pick';
public static function options()
{
return [
self::None->value => '无',
self::Express->value => '快递',
self::Pick->value => '自提',
];
}
public function text()
{
return data_get(self::options(), $this->value);
}
public function color()
{
return match ($this) {
static::None => 'secondary',
static::Express => 'primary',
static::Pick => 'warning',
};
}
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>";
}
}