Skip to content

Commit

Permalink
Merge pull request #466 from code4romania/225-ngo-admin-specialist-ca…
Browse files Browse the repository at this point in the history
…zuri-istoric-modificari-filter-on-istoric-modificari-table-doesnt-work

Beneficiary history - filters
  • Loading branch information
gheorghelupu17 authored Dec 31, 2024
2 parents 9d1b175 + 5328edb commit c9d19ba
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
use App\Concerns\HasParentResource;
use App\Enums\ActivityDescription;
use App\Filament\Organizations\Resources\BeneficiaryHistoryResource;
use App\Filters\DateFilter;
use App\Models\Activity;
use App\Models\Beneficiary;
use App\Models\User;
use App\Services\Breadcrumb\BeneficiaryBreadcrumb;
use App\Tables\Columns\DateColumn;
use App\Tables\Filters\SelectFilter;
use Filament\Resources\Pages\ListRecords;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -51,8 +53,8 @@ public function getTitle(): string|Htmlable
public function table(Table $table): Table
{
return $table
->query(
fn () => Activity::whereMorphedTo('subject', $this->parent)
->modifyQueryUsing(
fn (Builder $query) => $query->whereMorphedTo('subject', $this->parent)
->when(
! auth()->user()->hasAccessToAllCases() && ! auth()->user()->isNgoAdmin(),
fn (Builder $query) => $query->whereHasMorph(
Expand Down Expand Up @@ -108,11 +110,14 @@ public function table(Table $table): Table
? $query->where('description', $state['value'])
: $query
),
]);
}

protected function applyFiltersToTableQuery(Builder $query): Builder
{
return $query;
SelectFilter::make('causer_id')
->label(__('beneficiary.section.history.labels.user'))
->options(User::getTenantOrganizationUsers()),

DateFilter::make('created_at')
->label(__('beneficiary.section.history.labels.date')),

]);
}
}

0 comments on commit c9d19ba

Please sign in to comment.