@@ -453,8 +453,11 @@ public function getUniversalFeatures(Request $request) {
453453 $ features = count ($ categories ) ?
454454 $ features ->orderByRaw ('FIELD(feature_category_id, ' .implode (', ' , $ categories ->pluck ('id ' )->toArray ()).') ' ) :
455455 $ features ;
456- $ features = $ features ->orderByRaw ('FIELD(rarity_id, ' .implode (', ' , $ rarities ->pluck ('id ' )->toArray ()).') ' )
457- ->orderBy ('has_image ' , 'DESC ' )
456+ $ features = count ($ rarities ) ?
457+ $ features ->orderByRaw ('FIELD(rarity_id, ' .implode (', ' , $ rarities ->pluck ('id ' )->toArray ()).') ' ) :
458+ $ features ;
459+
460+ $ features ->orderBy ('has_image ' , 'DESC ' )
458461 ->orderBy ('name ' )
459462 ->get ()->groupBy (['feature_category_id ' , 'id ' ]);
460463
@@ -493,15 +496,17 @@ public function getKitchenSinkFeatures(Request $request) {
493496 $ categories = FeatureCategory::orderBy ('sort ' , 'DESC ' )->get ();
494497 $ rarities = Rarity::orderBy ('sort ' , 'ASC ' )->get ();
495498
499+ $ features = Feature::visible (Auth::user () ?? null );
500+
496501 $ features = count ($ categories ) ?
497- $ query = Feature:: visible (Auth:: user () ?? null ) ->orderByRaw ('FIELD(feature_category_id, ' .implode (', ' , $ categories ->pluck ('id ' )->toArray ()).') ' )
498- -> orderByRaw ( ' FIELD(rarity_id, ' . implode ( ' , ' , $ rarities -> pluck ( ' id ' )-> toArray ()). ' ) ' )
499- -> orderBy ( ' has_image ' , ' DESC ' )
500- -> orderBy ( ' name ' )
501- -> get ()
502- -> groupBy ([ ' feature_category_id ' , ' id ' ]) :
503- $ query = Feature:: visible (Auth:: user () ?? null )-> orderByRaw ( ' FIELD(rarity_id, ' . implode ( ' , ' , $ rarities -> pluck ( ' id ' )-> toArray ()). ' ) ' )
504- ->orderBy ('has_image ' , 'DESC ' )
502+ $ features ->orderByRaw ('FIELD(feature_category_id, ' .implode (', ' , $ categories ->pluck ('id ' )->toArray ()).') ' ) :
503+ $ features ;
504+
505+ $ features = count ( $ rarities ) ?
506+ $ features -> orderByRaw ( ' FIELD(rarity_id, ' . implode ( ' , ' , $ rarities -> pluck ( ' id ' )-> toArray ()). ' ) ' ) :
507+ $ features ;
508+
509+ $ features ->orderBy ('has_image ' , 'DESC ' )
505510 ->orderBy ('name ' )
506511 ->get ()
507512 ->groupBy (['feature_category_id ' , 'id ' ]);
0 commit comments