修复类别修改错误优化类别列表
This commit is contained in:
1 parent
0305278b47
commit
6c069592ef
5 files changed
+30
-8
No files matched your search
@@ -53,6 +53,13 @@ class Category extends Base
|
||||
//查询数据
|
||||
$data =CG::field('id,title,pid,status,paixu')
|
||||
->order([$order_field=>$order])
|
||||
->with(
|
||||
[
|
||||
'glPid'=>function($query){
|
||||
$query->field('id,title');
|
||||
},
|
||||
]
|
||||
)
|
||||
->limit($limit_start,$limit_length)
|
||||
->all();
|
||||
|
||||
@@ -64,6 +71,13 @@ class Category extends Base
|
||||
->whereOr('pid','in',function($query) use ($search){
|
||||
$query->name('category')->where('title','like','%'.$search.'%')->field('id');
|
||||
})
|
||||
->with(
|
||||
[
|
||||
'glPid'=>function($query){
|
||||
$query->field('id,title');
|
||||
},
|
||||
]
|
||||
)
|
||||
->order([$order_field=>$order])
|
||||
->limit($limit_start,$limit_length)
|
||||
->select();
|
||||
|
||||
@@ -9,9 +9,15 @@ class Category extends Base
|
||||
// 关闭全局自动时间戳
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
// 父级类别获取器
|
||||
public function getPidAttr($value)
|
||||
// // 父级类别获取器
|
||||
// public function getPidAttr($value)
|
||||
// {
|
||||
// return $this->where('id',$value)->value('title');
|
||||
// }
|
||||
|
||||
// 本模型关联
|
||||
public function glPid()
|
||||
{
|
||||
return $this->where('id',$value)->value('title');
|
||||
return $this->belongsTo('Category','pid','id');
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
<select class="select" id="pidt" name="pid" size="1" required>
|
||||
<option value="">--请选择父级权限--</option>
|
||||
{volist name="$ctp" id="vo"}
|
||||
<option value="{$vo.id}" {eq name="$list.pid" value="$vo.title" }selected{/eq}>{$vo.title}</option>
|
||||
<option value="{$vo.id}" {eq name="$list.pid" value="$vo.id" }selected{/eq}>{$vo.title}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</span>
|
||||
|
||||
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user