@@ -33,34 +33,59 @@ public function __construct()
3333 /**
3434 * Display a listing of the resource on the dashboard.
3535 */
36- public function dash (): View
36+ public function dash (Request $ request ): View
3737 {
3838 $ treat_tags_as = \App \Setting::fetch ('treat_tags_as ' );
3939
4040 $ data ["treat_tags_as " ] = $ treat_tags_as ;
4141
42- if ($ treat_tags_as == 'categories ' ) {
43- $ data ['categories ' ] = Item::whereHas ('children ' )->with ('children ' , function ($ query ) {
44- $ query ->pinned ()->orderBy ('order ' , 'asc ' );
45- })->pinned ()->orderBy ('order ' , 'asc ' )->get ();
46-
47- } elseif ($ treat_tags_as == 'tags ' ) {
48- $ data ['apps ' ] = Item::with ('parents ' )->where ('type ' , 0 )->pinned ()->orderBy ('order ' , 'asc ' )->get ();
49- $ data ['all_apps ' ] = Item::where ('type ' , 0 )->orderBy ('order ' , 'asc ' )->get ();
50- $ data ['taglist ' ] = Item::where ('id ' , 0 )->orWhere (function ($ query ) {
51- $ query ->where ('type ' , 1 )->pinned ();
52- })->orderBy ('order ' , 'asc ' )->get ();
42+ if (config ('app.auth_roles_enable ' )) {
43+ $ roles = explode (config ('app.auth_roles_delimiter ' ), $ request ->header (config ('app.auth_roles_header ' )));
44+ if ($ treat_tags_as == 'categories ' ) {
45+ $ data ['categories ' ] = Item::whereHas ('children ' )->with ('children ' , function ($ query ) {
46+ $ query ->pinned ()->orderBy ('order ' , 'asc ' );
47+ })->pinned ()->orderBy ('order ' , 'asc ' )->get ();
48+
49+ } elseif ($ treat_tags_as == 'tags ' ) {
50+ $ data ['apps ' ] = Item::with ('parents ' )->where ('type ' , 0 )->pinned ()->orderBy ('order ' , 'asc ' )->get ();
51+ $ data ['all_apps ' ] = Item::where ('type ' , 0 )->orderBy ('order ' , 'asc ' )->get ();
52+ $ data ['taglist ' ] = Item::where ('id ' , 0 )->orWhere (function ($ query ) {
53+ $ query ->where ('type ' , 1 )->pinned ();
54+ })->orderBy ('order ' , 'asc ' )->get ();
55+ } else {
56+
57+ $ data ['apps ' ] = Item::whereHas ('parents ' , function ($ query ) {
58+ $ query ->where ('id ' , 0 );
59+ })->whereIn ('role ' , $ roles )->orWhere ('type ' , 1 )->pinned ()->orderBy ('order ' , 'asc ' )->get ();
60+
61+ $ data ['all_apps ' ] = Item::whereHas ('parents ' , function ($ query ) {
62+ $ query ->where ('id ' , 0 );
63+ })->orWhere ('type ' , 1 )->orderBy ('order ' , 'asc ' )->get ();
64+ }
5365 } else {
54-
55- $ data ['apps ' ] = Item::whereHas ('parents ' , function ($ query ) {
56- $ query ->where ('id ' , 0 );
57- })->orWhere ('type ' , 1 )->pinned ()->orderBy ('order ' , 'asc ' )->get ();
58-
59- $ data ['all_apps ' ] = Item::whereHas ('parents ' , function ($ query ) {
60- $ query ->where ('id ' , 0 );
61- })->orWhere (function ($ query ) {
62- $ query ->where ('type ' , 1 )->whereNot ('id ' , 0 );
63- })->orderBy ('order ' , 'asc ' )->get ();
66+ if ($ treat_tags_as == 'categories ' ) {
67+ $ data ['categories ' ] = Item::whereHas ('children ' )->with ('children ' , function ($ query ) {
68+ $ query ->pinned ()->orderBy ('order ' , 'asc ' );
69+ })->pinned ()->orderBy ('order ' , 'asc ' )->get ();
70+
71+ } elseif ($ treat_tags_as == 'tags ' ) {
72+ $ data ['apps ' ] = Item::with ('parents ' )->where ('type ' , 0 )->pinned ()->orderBy ('order ' , 'asc ' )->get ();
73+ $ data ['all_apps ' ] = Item::where ('type ' , 0 )->orderBy ('order ' , 'asc ' )->get ();
74+ $ data ['taglist ' ] = Item::where ('id ' , 0 )->orWhere (function ($ query ) {
75+ $ query ->where ('type ' , 1 )->pinned ();
76+ })->orderBy ('order ' , 'asc ' )->get ();
77+ } else {
78+
79+ $ data ['apps ' ] = Item::whereHas ('parents ' , function ($ query ) {
80+ $ query ->where ('id ' , 0 );
81+ })->orWhere ('type ' , 1 )->pinned ()->orderBy ('order ' , 'asc ' )->get ();
82+
83+ $ data ['all_apps ' ] = Item::whereHas ('parents ' , function ($ query ) {
84+ $ query ->where ('id ' , 0 );
85+ })->orWhere (function ($ query ) {
86+ $ query ->where ('type ' , 1 )->whereNot ('id ' , 0 );
87+ })->orderBy ('order ' , 'asc ' )->get ();
88+ }
6489 }
6590
6691 //$data['all_apps'] = Item::doesntHave('parents')->get();
0 commit comments