Skip to content

Commit

Permalink
fix: subtype features
Browse files Browse the repository at this point in the history
  • Loading branch information
ScuffedNewt committed Oct 8, 2024
1 parent 20c6699 commit ccf67f5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/WorldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public function getSubtypeFeatures($id, Request $request) {
} else {
$features = $features
->filter(function ($feature) use ($subtype) {
return !($feature->subtype && $feature->subtype->id != $subtype->id);
return !($feature->subtypd_ids && !in_array($subtype->id, $feature->subtype_ids));
})
->groupBy(['feature_category_id', 'id']);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Species/Species.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function getSearchUrlAttribute() {
* @return string
*/
public function getVisualTraitsUrlAttribute() {
return url('/world/species/'.$this->id.'/traits');
return url('world/species/'.$this->id.'/traits');
}

/**
Expand Down
24 changes: 16 additions & 8 deletions app/Models/Species/Subtype.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ public function species() {
return $this->belongsTo(Species::class, 'species_id');
}

/**
* Get the features associated with this subtype.
*/
public function features() {
return $this->hasMany(Feature::class);
}

/**********************************************************************************************
SCOPES
Expand Down Expand Up @@ -184,7 +177,7 @@ public function getSearchUrlAttribute() {
* @return string
*/
public function getVisualTraitsUrlAttribute() {
return url('/world/subtypes/'.$this->id.'/traits');
return url('world/subtypes/'.$this->id.'/traits');
}

/**
Expand All @@ -204,4 +197,19 @@ public function getAdminUrlAttribute() {
public function getAdminPowerAttribute() {
return 'edit_data';
}

/**********************************************************************************************
OTHER FUNCTIONS
**********************************************************************************************/

/**
* Get the features associated with this subtype.
*/
public function features() {
return Feature::all()->filter(function ($feature) {
return in_array($this->id, $feature->subtypes_ids ?? []);
});
}
}
2 changes: 1 addition & 1 deletion resources/views/world/_subtype_entry.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<i class="fas fa-search"></i>
</a>
</h3>
@if (count($subtype->features) && config('lorekeeper.extensions.visual_trait_index.enable_subtype_index'))
@if (count($subtype->features()) && config('lorekeeper.extensions.visual_trait_index.enable_subtype_index'))
<a href="{{ $subtype->visualTraitsUrl }}">
<strong>Visual Trait Index</strong>
</a>
Expand Down

0 comments on commit ccf67f5

Please sign in to comment.