mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-10 23:36:08 -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()
|
||||
{
|
||||
$dBName = 'default_cats_category';
|
||||
$dBName = 'cats_category';
|
||||
$dBNamet = $dBName . '_translations';
|
||||
|
||||
$catsDB = DB::table((DB::raw($dBName . ' c1')))
|
||||
$catsDB = DB::table($dBName . ' as c1')
|
||||
->select(
|
||||
DB::raw('c1.id'),
|
||||
DB::raw('c1.slug'),
|
||||
DB::raw('c1.parent_category_id'),
|
||||
DB::raw('c1.icon_id'),
|
||||
DB::raw('t1.name'),
|
||||
|
||||
DB::raw('c2.id as c2_id'),
|
||||
DB::raw('c2.slug as c2_slug'),
|
||||
DB::raw('c2.parent_category_id as c2_parent_category_id'),
|
||||
DB::raw('t2.name as c2_name'),
|
||||
|
||||
DB::raw('file.id as file_id')
|
||||
'c1.id',
|
||||
'c1.slug',
|
||||
'c1.parent_category_id',
|
||||
'c1.icon_id',
|
||||
't1.name',
|
||||
'c2.id as c2_id',
|
||||
'c2.slug as c2_slug',
|
||||
'c2.parent_category_id as c2_parent_category_id',
|
||||
't2.name as c2_name',
|
||||
'file.id as file_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 . ' t2')), DB::raw('c2.id'), '=', DB::raw('t2.entry_id'))
|
||||
->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')))
|
||||
->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)
|
||||
->whereNull(DB::raw("c1.parent_category_id"))
|
||||
->orderBy(DB::raw("c1.sort_order"))
|
||||
->orderBy(DB::raw("c2.sort_order"))
|
||||
->leftJoin($dBName . ' as c2', function ($join) {
|
||||
$join->on('c2.parent_category_id', '=', 'c1.id')
|
||||
->whereNull('c2.deleted_at');
|
||||
})
|
||||
->leftJoin($dBNamet . ' as t1', function ($join) use ($dBNamet) {
|
||||
$join->on('c1.id', '=', 't1.entry_id')
|
||||
->where('t1.locale', Request()->session()->get('_locale', setting_value('streams::default_locale')));
|
||||
})
|
||||
->leftJoin($dBNamet . ' as t2', function ($join) use ($dBNamet) {
|
||||
$join->on('c2.id', '=', 't2.entry_id')
|
||||
->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();
|
||||
$cats = collect([]);
|
||||
$cats->subcats = $catsDB;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user