52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace app\common\service;
|
|
|
|
use app\admin\validate\SysDictValidate;
|
|
use app\common\logic\SysDictLogic;
|
|
use app\common\traits\crud\CrudServiceTrait;
|
|
use app\common\model\SysDict;
|
|
use support\Request;
|
|
|
|
class SysDictService
|
|
{
|
|
|
|
protected $logic;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->logic = (new SysDictLogic());
|
|
}
|
|
|
|
/**
|
|
* 获取系统list
|
|
*/
|
|
public function getList()
|
|
{
|
|
return $this->logic->getList();
|
|
}
|
|
|
|
|
|
|
|
public static function pluckValuesByCode(string $dictCode): array
|
|
{
|
|
return SysDict::where('dict_code', $dictCode)
|
|
->where('status', 1)
|
|
->first()?->items()
|
|
->where('status', 1)
|
|
->orderBy('sort')
|
|
->pluck('item_value')
|
|
->toArray() ?? [];
|
|
}
|
|
|
|
public static function pluckKeyValueByCode(string $dictCode): array
|
|
{
|
|
return SysDict::where('dict_code', $dictCode)
|
|
->where('status', 1)
|
|
->first()?->items()
|
|
->where('status', 1)
|
|
->orderBy('sort')
|
|
->pluck('item_value', 'item_label')
|
|
->toArray() ?? [];
|
|
}
|
|
} |