修改分类
This commit is contained in:
@@ -344,11 +344,11 @@ class TopicNas extends Common
|
|||||||
->where('category_id', 'IN', array_column($categorys, 'id'))
|
->where('category_id', 'IN', array_column($categorys, 'id'))
|
||||||
->select();
|
->select();
|
||||||
//查询上级id
|
//查询上级id
|
||||||
$parent_two = ArticleCategoryModel::ParentChild(array_column($categorys, 'id'))->language($this->lang_id)->column('pid','id');//二级分类id
|
$parent_two = ArticleCategoryModel::parentColumn(array_column($categorys, 'id'))->language($this->lang_id)->column('pid','id');//二级分类id
|
||||||
$articles_data = $articles->toArray();
|
$articles_data = $articles->toArray();
|
||||||
foreach ($articles_data as &$v) {
|
foreach ($articles_data as &$v) {
|
||||||
$v['pid'] = 0;
|
$v['pid'] = 0;
|
||||||
if ( isset($parent_two[$v['category_id']]) ) {
|
if ( $parent_two[$v['category_id']] !== $parent ) {
|
||||||
$v['pid'] = $v['category_id'];
|
$v['pid'] = $v['category_id'];
|
||||||
$v['category_id'] = $parent_two[$v['category_id']];
|
$v['category_id'] = $parent_two[$v['category_id']];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,16 @@ class ArticleCategoryModel extends ArticleCategoryBaseModel
|
|||||||
$query->where('pid', '=', $parent);
|
$query->where('pid', '=', $parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 所属上级分类查询
|
||||||
|
public function scopeParentColumn($query, $parent)
|
||||||
|
{
|
||||||
|
if (is_array($parent)) {
|
||||||
|
$query->where('id', 'IN', $parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$query->where('id', '=', $parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 所属子分类范围查询
|
// 所属子分类范围查询
|
||||||
public function scopeChild($query, $id, $merge_self = false)
|
public function scopeChild($query, $id, $merge_self = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user