优化扩展功能

This commit is contained in:
2020-04-04 21:53:38 +08:00
parent 98419ca360
commit a8619c61fb
11 changed files with 214 additions and 28 deletions

View File

@@ -77,7 +77,7 @@ class Attribute extends \think\Model {
}
protected function getTypeTextAttr($value, $data) {
$config_type_list = Config::get('config.config_type_list');
$config_type_list = Config::get('config.config_type_list') ?? [];
$type = [];
foreach ($config_type_list as $key => $value) {
$type[$value['key']] = $value['label'];
@@ -111,6 +111,9 @@ class Attribute extends \think\Model {
$map[] = ['model_id', '=', $data['model_id']];
}
$row = Db::name($extra[0])->where($map)->select()->toArray();
if(empty($row)){
return [];
}
if ($extra[1] == 'tree') {
$row = (new Tree())->toFormatTree($row);
foreach ($row as $val) {
@@ -146,7 +149,7 @@ class Attribute extends \think\Model {
$map[] = ['is_show', 'IN', [1, 3]];
}
$row = self::where($map)
$row = self::where($map)->order('sort asc, id desc')
->select()
->append(['option'])
->toArray();