Skip to content

Commit 4cee8d5

Browse files
fix: only show visible subtypes to user
1 parent 110f425 commit 4cee8d5

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

app/Models/Feature/Feature.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,15 @@ public function getAdminPowerAttribute() {
291291
292292
**********************************************************************************************/
293293

294+
/**
295+
* Gets the trait's subtypes that are visible to the current user.
296+
*
297+
* @param mixed|null $user
298+
*/
299+
public function getSubtypes($user = null) {
300+
return $this->subtypes()->visible($user)->get();
301+
}
302+
294303
/**
295304
* Displays the trait's subtypes as an imploded string.
296305
*

resources/views/world/_feature_entry.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
@if ($feature->species_id)
2626
<div>
2727
<strong>Species:</strong> {!! $feature->species->displayName !!}
28-
@if (!$feature->subtypes->isEmpty())
28+
@if (count($feature->getSubtypes(Auth::User() ?? null)))
2929
({!! $feature->displaySubtypes(Auth::User() ?? null) !!})
3030
@endif
3131
</div>

resources/views/world/_features_index.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<i class="fas fa-eye-slash mr-1"></i>
2323
@endif
2424
{!! $feature->first()->displayName !!}
25-
@if ($showSubtype && count($feature->first()->subtypes))
26-
<br />(Subtype{{ count($feature->first()->subtypes) > 1 ? 's' : '' }}: {!! $feature->first()->displaySubtypes(Auth::User() ?? null) !!})
25+
@if ($showSubtype && count($feature->first()->getSubtypes(Auth::User() ?? null)))
26+
<br />(Subtype{{ count($feature->first()->getSubtypes(Auth::User() ?? null)) > 1 ? 's' : '' }}: {!! $feature->first()->displaySubtypes(Auth::User() ?? null) !!})
2727
@endif
2828
</p>
2929
</div>

0 commit comments

Comments
 (0)