From e8af525eaf9307a210d9cd04b427e5409c78eacd Mon Sep 17 00:00:00 2001 From: SpeedyD Date: Fri, 9 Dec 2022 23:13:48 +0100 Subject: [PATCH 1/3] This will resolve characters not found on sales pages --- .../sales/_character_select_entry.blade.php | 6 +++--- resources/views/sales/_character.blade.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/resources/views/admin/sales/_character_select_entry.blade.php b/resources/views/admin/sales/_character_select_entry.blade.php index c373fbd325..8e1baa1d6d 100644 --- a/resources/views/admin/sales/_character_select_entry.blade.php +++ b/resources/views/admin/sales/_character_select_entry.blade.php @@ -14,7 +14,7 @@
{!! Form::label('slug[]', 'Character Code') !!} - {!! Form::text('slug[]', $character->character->slug, ['class' => 'form-control character-code']) !!} + {!! Form::text('slug[]', $character->character ? $character->character->slug : null, ['class' => 'form-control character-code']) !!}

Sale Details

@@ -77,11 +77,11 @@ @if ($sales->characters->count() > 1)
- {!! Form::checkbox('character_is_open[' . $character->character->slug . ']', 1, $character->is_open, ['class' => 'form-check-input', 'data-toggle' => 'toggle']) !!} + {!! Form::checkbox('character_is_open[' . ($character->character ? $character->character->slug : 'character-not-found') . ']', 1, $character->is_open, ['class' => 'form-check-input', 'data-toggle' => 'toggle']) !!} {!! Form::label('character_is_open', 'Is Open', ['class' => 'form-check-label ml-3']) !!} {!! add_help('Whether or not this particular character is open or available. If the sale post itself is closed, all character sales attached will also be displayed as closed.') !!}
@else - {!! Form::hidden('character_is_open[' . $character->character->slug . ']', 1) !!} + {!! Form::hidden('character_is_open[' . ($character->character ? $character->character->slug : 'character-not-found') . ']', 1) !!} @endif {!! Form::hidden('new_entry[]', 0) !!} diff --git a/resources/views/sales/_character.blade.php b/resources/views/sales/_character.blade.php index cfa4b5fd49..07610692e7 100644 --- a/resources/views/sales/_character.blade.php +++ b/resources/views/sales/_character.blade.php @@ -1,6 +1,7 @@
+ @if($character->character)
{{ $character->fullName }}
@@ -99,6 +100,24 @@ class="{{ $character->is_open && $character->sales->is_open ? 'text-success' : '

{!! $character->description !!}

+ @else +
+
Character not found.
+
+
+
+
+ Character not found. +
+ +
+ If you see this text, please contact an administrator. +
+ +

This should only occur if a character was deleted. This entry was likely left in error, or is currently in the process of being removed.

+
+
+ @endif
From d8047f3e037758c7d2f0a029379362f34783cfcb Mon Sep 17 00:00:00 2001 From: SpeedyD Date: Fri, 9 Dec 2022 22:14:59 +0000 Subject: [PATCH 2/3] refactor: fix blade formatting --- resources/views/sales/_character.blade.php | 214 ++++++++++----------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/resources/views/sales/_character.blade.php b/resources/views/sales/_character.blade.php index 07610692e7..ec4922b505 100644 --- a/resources/views/sales/_character.blade.php +++ b/resources/views/sales/_character.blade.php @@ -1,123 +1,123 @@
- @if($character->character) -
- {{ $character->fullName }} -
-
-
-
- {{ $character->displayType }}: {!! $character->character->slug !!}[{{ $character->is_open && $character->sales->is_open ? 'Open' : 'Closed' }}]
- - {!! $character->image->species->displayName !!} ・ {!! $character->image->rarity->displayName !!}
-
-
+ @if ($character->character) +
+ {{ $character->fullName }} +
+
+
+
+ {{ $character->displayType }}: {!! $character->character->slug !!}[{{ $character->is_open && $character->sales->is_open ? 'Open' : 'Closed' }}]
+ + {!! $character->image->species->displayName !!} ・ {!! $character->image->rarity->displayName !!}
+
+
- @if ($loop->count == 1) -
- @if (Config::get('lorekeeper.extensions.traits_by_category')) -
- @php - $traitgroup = $character->image - ->features() - ->get() - ->groupBy('feature_category_id'); - @endphp - @if ($character->image->features()->count()) - @foreach ($traitgroup as $key => $group) -
- @if ($group->count() > 1) -
+ @if ($loop->count == 1) +
+ @if (Config::get('lorekeeper.extensions.traits_by_category')) +
+ @php + $traitgroup = $character->image + ->features() + ->get() + ->groupBy('feature_category_id'); + @endphp + @if ($character->image->features()->count()) + @foreach ($traitgroup as $key => $group) +
+ @if ($group->count() > 1) +
+ {!! $key ? $group->first()->feature->category->displayName : 'Miscellaneous' !!}: + @foreach ($group as $feature) + {!! $feature->feature->displayName !!}@if ($feature->data) + ({{ $feature->data }}) + @endif{{ !$loop->last ? ', ' : '' }} + @endforeach +
+ @else {!! $key ? $group->first()->feature->category->displayName : 'Miscellaneous' !!}: - @foreach ($group as $feature) - {!! $feature->feature->displayName !!}@if ($feature->data) - ({{ $feature->data }}) - @endif{{ !$loop->last ? ', ' : '' }} - @endforeach -
- @else - {!! $key ? $group->first()->feature->category->displayName : 'Miscellaneous' !!}: - {!! $group->first()->feature->displayName !!} - @if ($group->first()->data) - ({{ $group->first()->data }}) - @endif - @endif -
- @endforeach - @else -
No traits listed.
- @endif -
- @else -
- image - ->features() - ->with('feature.category') - ->get(); ?> - @if ($features->count()) - @foreach ($features as $feature) -
- @if ($feature->feature->feature_category_id) - {!! $feature->feature->category->displayName !!}: - @endif {!! $feature->feature->displayName !!} @if ($feature->data) - ({{ $feature->data }}) + {!! $group->first()->feature->displayName !!} + @if ($group->first()->data) + ({{ $group->first()->data }}) + @endif @endif -
- @endforeach - @else -
No traits listed.
- @endif -
- @endif -
- @endif +
+ @endforeach + @else +
No traits listed.
+ @endif +
+ @else +
+ image + ->features() + ->with('feature.category') + ->get(); ?> + @if ($features->count()) + @foreach ($features as $feature) +
+ @if ($feature->feature->feature_category_id) + {!! $feature->feature->category->displayName !!}: + @endif {!! $feature->feature->displayName !!} @if ($feature->data) + ({{ $feature->data }}) + @endif +
+ @endforeach + @else +
No traits listed.
+ @endif +
+ @endif +
+ @endif -
-
- Design: - @foreach ($character->image->designers as $designer) - {!! $designer->displayLink() !!}{{ !$loop->last ? ', ' : '' }} - @endforeach ・ - Art: - @foreach ($character->image->artists as $artist) - {!! $artist->displayLink() !!}{{ !$loop->last ? ', ' : '' }} - @endforeach -
+
+
+ Design: + @foreach ($character->image->designers as $designer) + {!! $designer->displayLink() !!}{{ !$loop->last ? ', ' : '' }} + @endforeach ・ + Art: + @foreach ($character->image->artists as $artist) + {!! $artist->displayLink() !!}{{ !$loop->last ? ', ' : '' }} + @endforeach +
- {!! $character->price !!} - {!! isset($character->link) || isset($character->data['end_point']) ? '
' : '' !!} - @if (isset($character->data['end_point'])) - {{ $character->data['end_point'] }} - @endif - {{ isset($character->link) && (!isset($character->sales->comments_open_at) || (Auth::check() && Auth::user()->hasPower('edit_pages')) || $character->sales->comments_open_at < Carbon\Carbon::now()) && isset($character->data['end_point']) ? ' ・ ' : '' }} - @if (isset($character->link) && (!isset($character->sales->comments_open_at) || (Auth::check() && Auth::user()->hasPower('edit_pages')) || $character->sales->comments_open_at < Carbon\Carbon::now())) - {{ $character->typeLink }} - @endif -
+ {!! $character->price !!} + {!! isset($character->link) || isset($character->data['end_point']) ? '
' : '' !!} + @if (isset($character->data['end_point'])) + {{ $character->data['end_point'] }} + @endif + {{ isset($character->link) && (!isset($character->sales->comments_open_at) || (Auth::check() && Auth::user()->hasPower('edit_pages')) || $character->sales->comments_open_at < Carbon\Carbon::now()) && isset($character->data['end_point']) ? ' ・ ' : '' }} + @if (isset($character->link) && (!isset($character->sales->comments_open_at) || (Auth::check() && Auth::user()->hasPower('edit_pages')) || $character->sales->comments_open_at < Carbon\Carbon::now())) + {{ $character->typeLink }} + @endif + -

{!! $character->description !!}

+

{!! $character->description !!}

+
+
+ @else +
+
Character not found.
-
- @else -
-
Character not found.
-
-
-
-
- Character not found. -
+
+
+
+ Character not found. +
-
- If you see this text, please contact an administrator. -
+
+ If you see this text, please contact an administrator. +
-

This should only occur if a character was deleted. This entry was likely left in error, or is currently in the process of being removed.

+

This should only occur if a character was deleted. This entry was likely left in error, or is currently in the process of being removed.

+
-
- @endif + @endif
From 34dc3b09a2b664f07bc98ff77887efffd9b5aaf4 Mon Sep 17 00:00:00 2001 From: SpeedyD Date: Mon, 12 Jun 2023 20:23:38 +0200 Subject: [PATCH 3/3] Ternary operators, someone? --- .../views/admin/sales/_character_select_entry.blade.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/views/admin/sales/_character_select_entry.blade.php b/resources/views/admin/sales/_character_select_entry.blade.php index 8e1baa1d6d..60fbf65bfc 100644 --- a/resources/views/admin/sales/_character_select_entry.blade.php +++ b/resources/views/admin/sales/_character_select_entry.blade.php @@ -14,7 +14,7 @@
{!! Form::label('slug[]', 'Character Code') !!} - {!! Form::text('slug[]', $character->character ? $character->character->slug : null, ['class' => 'form-control character-code']) !!} + {!! Form::text('slug[]', $character->character->slug ?? null, ['class' => 'form-control character-code']) !!}

Sale Details

@@ -77,11 +77,11 @@ @if ($sales->characters->count() > 1)
- {!! Form::checkbox('character_is_open[' . ($character->character ? $character->character->slug : 'character-not-found') . ']', 1, $character->is_open, ['class' => 'form-check-input', 'data-toggle' => 'toggle']) !!} + {!! Form::checkbox('character_is_open[' . ($$character->character->slug ?? 'character-not-found') . ']', 1, $character->is_open, ['class' => 'form-check-input', 'data-toggle' => 'toggle']) !!} {!! Form::label('character_is_open', 'Is Open', ['class' => 'form-check-label ml-3']) !!} {!! add_help('Whether or not this particular character is open or available. If the sale post itself is closed, all character sales attached will also be displayed as closed.') !!}
@else - {!! Form::hidden('character_is_open[' . ($character->character ? $character->character->slug : 'character-not-found') . ']', 1) !!} + {!! Form::hidden('character_is_open[' . ($character->character->slug ?? 'character-not-found') . ']', 1) !!} @endif {!! Form::hidden('new_entry[]', 0) !!}