mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
#3334 Subworkit needs
This commit is contained in:
parent
9bf5914e51
commit
f74182ee3a
@ -112,35 +112,39 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
|
|||||||
|
|
||||||
public function getMainAndSubCats()
|
public function getMainAndSubCats()
|
||||||
{
|
{
|
||||||
$dBName = 'default_cats_category';
|
$dBName = 'cats_category';
|
||||||
$dBNamet = $dBName . '_translations';
|
$dBNamet = $dBName . '_translations';
|
||||||
|
|
||||||
$catsDB = DB::table((DB::raw($dBName . ' c1')))
|
$catsDB = DB::table($dBName . ' as c1')
|
||||||
->select(
|
->select(
|
||||||
DB::raw('c1.id'),
|
'c1.id',
|
||||||
DB::raw('c1.slug'),
|
'c1.slug',
|
||||||
DB::raw('c1.parent_category_id'),
|
'c1.parent_category_id',
|
||||||
DB::raw('c1.icon_id'),
|
'c1.icon_id',
|
||||||
DB::raw('t1.name'),
|
't1.name',
|
||||||
|
'c2.id as c2_id',
|
||||||
DB::raw('c2.id as c2_id'),
|
'c2.slug as c2_slug',
|
||||||
DB::raw('c2.slug as c2_slug'),
|
'c2.parent_category_id as c2_parent_category_id',
|
||||||
DB::raw('c2.parent_category_id as c2_parent_category_id'),
|
't2.name as c2_name',
|
||||||
DB::raw('t2.name as c2_name'),
|
'file.id as file_id'
|
||||||
|
|
||||||
DB::raw('file.id as file_id')
|
|
||||||
)
|
)
|
||||||
->leftJoin((DB::raw($dBName . ' c2')), DB::raw('c2.parent_category_id'), '=', DB::raw('c1.id'))
|
->leftJoin($dBName . ' as c2', function ($join) {
|
||||||
->leftJoin((DB::raw($dBNamet . ' t1')), DB::raw('c1.id'), '=', DB::raw('t1.entry_id'))
|
$join->on('c2.parent_category_id', '=', 'c1.id')
|
||||||
->leftJoin((DB::raw($dBNamet . ' t2')), DB::raw('c2.id'), '=', DB::raw('t2.entry_id'))
|
->whereNull('c2.deleted_at');
|
||||||
->leftJoin(DB::raw('default_files_files file'), DB::raw('c1.icon_id'), DB::raw('file.id'))
|
})
|
||||||
->where(DB::raw('t1.locale'), Request()->session()->get('_locale', setting_value('streams::default_locale')))
|
->leftJoin($dBNamet . ' as t1', function ($join) use ($dBNamet) {
|
||||||
->where(DB::raw('t2.locale'), Request()->session()->get('_locale', setting_value('streams::default_locale')))
|
$join->on('c1.id', '=', 't1.entry_id')
|
||||||
->where(DB::raw("c1.deleted_at"), NULL)
|
->where('t1.locale', Request()->session()->get('_locale', setting_value('streams::default_locale')));
|
||||||
->where(DB::raw("c2.deleted_at"), NULL)
|
})
|
||||||
->whereNull(DB::raw("c1.parent_category_id"))
|
->leftJoin($dBNamet . ' as t2', function ($join) use ($dBNamet) {
|
||||||
->orderBy(DB::raw("c1.sort_order"))
|
$join->on('c2.id', '=', 't2.entry_id')
|
||||||
->orderBy(DB::raw("c2.sort_order"))
|
->where('t2.locale', Request()->session()->get('_locale', setting_value('streams::default_locale')));
|
||||||
|
})
|
||||||
|
->leftJoin('files_files as file', 'c1.icon_id', 'file.id')
|
||||||
|
->whereNull('c1.deleted_at')
|
||||||
|
->whereNull('c1.parent_category_id')
|
||||||
|
->orderBy('c1.sort_order')
|
||||||
|
->orderBy('c2.sort_order')
|
||||||
->get();
|
->get();
|
||||||
$cats = collect([]);
|
$cats = collect([]);
|
||||||
$cats->subcats = $catsDB;
|
$cats->subcats = $catsDB;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user