© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•17mo ago•
1 reply
Areslane

table filters are not working when i customized getEloquentQuery()

public static function getEloquentQuery(): Builder
{
// Apply custom authorization and query modifications
if (!auth()->user()->can("viewAny")) {
$subordinateIds = auth()->user()->subordinates()->pluck('id');

// Ensure the query context is for MyEvent model
$createdByUserOrSubordinates = function ($query) use ($subordinateIds) {
$query->whereIn('creator_id', [...$subordinateIds, auth()->id()]);
};

// Ensure the query context is for MyEvent model
$eventHasAuthUserOrSubordinates = function ($query) use ($subordinateIds) {
$query->whereIn('worker_id', [...$subordinateIds, auth()->id()]);
};

// Apply conditions to the query
return parent::getEloquentQuery()->where($createdByUserOrSubordinates)
->orWhereHas('eventWorkers', $eventHasAuthUserOrSubordinates);
}

return parent::getEloquentQuery();
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to use table filters in getEloquentQuery?
FilamentFFilament / ❓┊help
2y ago
ManageRelatedRecords use getEloquentQuery() not working
FilamentFFilament / ❓┊help
2y ago
page filters not working on table widget
FilamentFFilament / ❓┊help
8mo ago
Table colulmns only add when certain filters are applied
FilamentFFilament / ❓┊help
9mo ago