开始优化类别获取

This commit is contained in:
win7 committed 2019-12-19 16:59:11 +08:00
1 parent 6d1d18b48b
commit e3be1c24cb
11 files changed
+47 -72

No files matched your search

+13 -4
View File
@@ -12,18 +12,27 @@
// 应用公共文件
// 获取类别列表
function getCategory($id = '0')
function getCategory($id = '0',$title='')
{
dump($id);
dump($title);
$category = new \app\system\model\Category;
// 根据父级id查询类别列表
$list = $category
->where('pid',$id)
->when(strlen($title)>0,function($q) use($title){
$q->where('title',$title);
},function($q) use($id){
$q->where('pid',$id);
})
->where('status',1)
->field('id,title')
->fetchSql(true)
->select();
halt($list);
// 返回类别列表
return $list;
}