mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-28 00:24:41 -06:00
#4237 The main category does not appear if the subcategory is not attached.
This commit is contained in:
parent
668f01bab2
commit
f987be6bc2
@ -44,36 +44,38 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
|
|||||||
$dBName = 'default_cats_category';
|
$dBName = 'default_cats_category';
|
||||||
$dBNamet = $dBName . '_translations';
|
$dBNamet = $dBName . '_translations';
|
||||||
|
|
||||||
$catsDB = DB::table((DB::raw($dBName . ' c1')))
|
$catsDB = DB::table((DB::raw($dBName . ' c1')))
|
||||||
->select(
|
->select(
|
||||||
DB::raw('c1.id'),
|
DB::raw('c1.id'),
|
||||||
DB::raw('c1.slug'),
|
DB::raw('c1.slug'),
|
||||||
DB::raw('c1.icon'),
|
DB::raw('c1.icon'),
|
||||||
DB::raw('c1.count'),
|
DB::raw('c1.count'),
|
||||||
DB::raw('c1.parent_category_id'),
|
DB::raw('c1.parent_category_id'),
|
||||||
DB::raw('t1.name'),
|
DB::raw('t1.name'),
|
||||||
|
|
||||||
DB::raw('c2.id as c2_id'),
|
DB::raw('c2.id as c2_id'),
|
||||||
DB::raw('c2.slug as c2_slug'),
|
DB::raw('c2.slug as c2_slug'),
|
||||||
DB::raw('c2.count as c2_count'),
|
DB::raw('c2.count as c2_count'),
|
||||||
DB::raw('c2.parent_category_id as c2_parent_category_id'),
|
DB::raw('c2.parent_category_id as c2_parent_category_id'),
|
||||||
DB::raw('t2.name as c2_name')
|
DB::raw('t2.name as c2_name')
|
||||||
)
|
)
|
||||||
->leftJoin((DB::raw($dBName . ' c2')), DB::raw('c2.parent_category_id'), '=', DB::raw('c1.id'))
|
->leftJoin((DB::raw($dBName . ' c2')), DB::raw('c2.parent_category_id'), '=', DB::raw('c1.id'))
|
||||||
->leftJoin((DB::raw($dBNamet . ' t1')), DB::raw('c1.id'), '=', DB::raw('t1.entry_id'))
|
->leftJoin((DB::raw($dBNamet . ' t1')), DB::raw('c1.id'), '=', DB::raw('t1.entry_id'))
|
||||||
->leftJoin((DB::raw($dBNamet . ' t2')), DB::raw('c2.id'), '=', DB::raw('t2.entry_id'))
|
->leftJoin((DB::raw($dBNamet . ' t2')), function ($join) {
|
||||||
->where(DB::raw('t1.locale'), Request()->session()->get('_locale', setting_value('streams::default_locale')))
|
$join->on(DB::raw('c2.id'), '=', DB::raw('t2.entry_id'))
|
||||||
->where(DB::raw('t2.locale'), Request()->session()->get('_locale', setting_value('streams::default_locale')))
|
->where(DB::raw('t2.locale'), Request()->session()->get('_locale', setting_value('streams::default_locale')));
|
||||||
->where(DB::raw("c1.deleted_at"), NULL)
|
})
|
||||||
->where(DB::raw("c2.deleted_at"), NULL)
|
->where(DB::raw('t1.locale'), Request()->session()->get('_locale', setting_value('streams::default_locale')))
|
||||||
->whereNull(DB::raw("c1.parent_category_id"))
|
->where(DB::raw("c1.deleted_at"), NULL)
|
||||||
->orderBy(DB::raw("c1.sort_order"))
|
->where(DB::raw("c2.deleted_at"), NULL)
|
||||||
->orderBy(DB::raw("c2.sort_order"))
|
->whereNull(DB::raw("c1.parent_category_id"))
|
||||||
->get();
|
->orderBy(DB::raw("c1.sort_order"))
|
||||||
$cats = collect([]);
|
->orderBy(DB::raw("c2.sort_order"))
|
||||||
$cats->subcats = $catsDB;
|
->get();
|
||||||
$cats->maincats = $catsDB->unique('id');
|
$cats = collect([]);
|
||||||
return $cats;
|
$cats->subcats = $catsDB;
|
||||||
|
$cats->maincats = $catsDB->unique('id');
|
||||||
|
return $cats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCategoryById($id)
|
public function getCategoryById($id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user