From 04d6af6e2ee529c634249351ab4ff492b165a687 Mon Sep 17 00:00:00 2001 From: SpeedyD Date: Mon, 5 Feb 2024 20:57:16 +0100 Subject: [PATCH 1/2] fix(items/features): Makes hidden traits and unreleased items visible for staff. --- app/Http/Controllers/WorldController.php | 19 ++++++++++++++----- .../views/world/_feature_entry.blade.php | 3 +++ resources/views/world/_item_entry.blade.php | 3 +++ resources/views/world/item_page.blade.php | 7 ++++++- .../views/world/species_features.blade.php | 3 +++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/WorldController.php b/app/Http/Controllers/WorldController.php index 08c160136d..e77ebddd45 100644 --- a/app/Http/Controllers/WorldController.php +++ b/app/Http/Controllers/WorldController.php @@ -147,7 +147,7 @@ public function getFeatureCategories(Request $request) { * @return \Illuminate\Contracts\Support\Renderable */ public function getFeatures(Request $request) { - $query = Feature::visible()->with('category')->with('rarity')->with('species'); + $query = Feature::visible(Auth::check() ? Auth::user() : null)->with('category')->with('rarity')->with('species'); $data = $request->only(['rarity_id', 'feature_category_id', 'species_id', 'subtype_id', 'name', 'sort']); if (isset($data['rarity_id']) && $data['rarity_id'] != 'none') { $query->where('rarity_id', $data['rarity_id']); @@ -240,7 +240,7 @@ public function getSpeciesFeatures($id) { $features = count($categories) ? $species->features() - ->visible() + ->visible(Auth::check() ? Auth::user() : null) ->orderByRaw('FIELD(feature_category_id,'.implode(',', $categories->pluck('id')->toArray()).')') ->orderByRaw('FIELD(rarity_id,'.implode(',', $rarities->pluck('id')->toArray()).')') ->orderBy('has_image', 'DESC') @@ -255,7 +255,7 @@ public function getSpeciesFeatures($id) { }) ->groupBy(['feature_category_id', 'id']) : $species->features() - ->visible() + ->visible(Auth::check() ? Auth::user() : null) ->orderByRaw('FIELD(rarity_id,'.implode(',', $rarities->pluck('id')->toArray()).')') ->orderBy('has_image', 'DESC') ->orderBy('name') @@ -306,7 +306,11 @@ public function getSpeciesFeatureDetail($speciesId, $id) { * @return \Illuminate\Contracts\Support\Renderable */ public function getItems(Request $request) { - $query = Item::with('category')->released(); + $query = Item::with('category'); + + if (!Auth::check() || !Auth::user()->isStaff) { + $query->released(); + } $categoryVisibleCheck = ItemCategory::visible(Auth::check() ? Auth::user() : null)->pluck('id', 'name')->toArray(); // query where category is visible, or, no category and released @@ -367,7 +371,12 @@ public function getItems(Request $request) { */ public function getItem($id) { $categories = ItemCategory::orderBy('sort', 'DESC')->get(); - $item = Item::where('id', $id)->released()->first(); + + if (!Auth::check() || !Auth::user()->isStaff) { + $item = Item::where('id', $id)->released()->first(); + } else { + $item = Item::where('id', $id)->first(); + } if (!$item) { abort(404); } diff --git a/resources/views/world/_feature_entry.blade.php b/resources/views/world/_feature_entry.blade.php index 02f4956533..71eee4909a 100644 --- a/resources/views/world/_feature_entry.blade.php +++ b/resources/views/world/_feature_entry.blade.php @@ -9,6 +9,9 @@

+ @if (!$feature->is_visible) + + @endif {!! $feature->displayName !!} diff --git a/resources/views/world/_item_entry.blade.php b/resources/views/world/_item_entry.blade.php index b649b31e41..62fcde7ca5 100644 --- a/resources/views/world/_item_entry.blade.php +++ b/resources/views/world/_item_entry.blade.php @@ -5,6 +5,9 @@

+ @if (!$item->is_released) + + @endif {!! $name !!} @if (isset($idUrl) && $idUrl) diff --git a/resources/views/world/item_page.blade.php b/resources/views/world/item_page.blade.php index 83421cc87b..a0da665e41 100644 --- a/resources/views/world/item_page.blade.php +++ b/resources/views/world/item_page.blade.php @@ -36,7 +36,12 @@
{{ $name }}
@endif
-

{!! $name !!}

+

+ @if (!$item->is_released) + + @endif + {!! $name !!} +

@if (isset($item->category) && $item->category)
diff --git a/resources/views/world/species_features.blade.php b/resources/views/world/species_features.blade.php index 43d1e27d91..43d3ba78a6 100644 --- a/resources/views/world/species_features.blade.php +++ b/resources/views/world/species_features.blade.php @@ -27,6 +27,9 @@ @endif

+ @if (!$feature->first()->is_visible) + + @endif {!! $feature->first()->displayName !!} @if ($feature->first()->subtype)
({!! $feature->first()->subtype->displayName !!} Subtype) From addfac21e511a05dc7c835df73d20041f18f3d5d Mon Sep 17 00:00:00 2001 From: SpeedyD Date: Mon, 5 Feb 2024 19:58:10 +0000 Subject: [PATCH 2/2] refactor: fix blade formatting --- resources/views/world/species_features.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/world/species_features.blade.php b/resources/views/world/species_features.blade.php index 43d3ba78a6..8c13b7d98f 100644 --- a/resources/views/world/species_features.blade.php +++ b/resources/views/world/species_features.blade.php @@ -28,7 +28,7 @@ @endif

@if (!$feature->first()->is_visible) - + @endif {!! $feature->first()->displayName !!} @if ($feature->first()->subtype)