Skip to content

Commit

Permalink
Easy filtering the taxonomy terms
Browse files Browse the repository at this point in the history
  • Loading branch information
NuwanJ committed Oct 17, 2024
1 parent 3aff0fa commit 62f22e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/Http/Livewire/Backend/TaxonomyTermTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public function query(): Builder
{
return TaxonomyTerm::query()
->where('taxonomy_id', $this->taxonomy->id)
->when($this->getFilter('taxonomy_term'), fn($query, $type) => $query->where('parent_id', $type))
->with('user');
->when($this->getFilter('taxonomy_term'), fn($query, $type) => $query->where('parent_id', $type)->orWhere('id', $type))
->with('user')->orderBy('parent_id');
}

public function filters(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

<x-livewire-tables::table.cell>
@if ($row->parent_id != null)
{{ $row->parent->name }}
<a href="?filters[taxonomy_term]={{ $row->parent->id }}" class="text-decoration-none">
{{ $row->parent->name }}
</a>
@else
N/A
@endif
Expand Down

0 comments on commit 62f22e5

Please sign in to comment.