© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•14mo ago•
7 replies
jmrufo

Problem editing filtered record

Hi guys. I hope someone can help me.

I have a table with data that is filtered before loading based on the role of the logged in user. In this way, the user only sees the records that he/she must manage. The query I use is the following:

public static function getEloquentQuery(): Builder
{
if (Auth::user()->hasRole('panel_user')) {
return parent::getEloquentQuery()->where('modality', 'TF');
} elseif (Auth::user()->hasRole('panel_user_presencial')) {
return parent::getEloquentQuery()->where('modality', '=','P')->Orwhere('modality', '=', 'M')->Orwhere('modality', '=', 'AV');
} else {
return parent::getEloquentQuery();
}
}

Los datos obtenidos son correctos para cada usuario, el problema ocurre cuando se intenta editar un registro, siempre edita el primero de la lista independientemente del que pulse.

Why does this happen? How can I solve it?

Thanks in advance
Solution
Hello

I have used the modifyQueryUsing() function on the table and the records it displays for each user are correct, however when editing a record the information it loads is still incorrect, that is, it always loads the information from the first record shown regardless of the one you select.

Example:
->modifyQueryUsing(function (Builder $query) {
if (Auth::user()->hasRole('panel_user')) {
return $query->where('modality', 'TF');
} elseif (Auth::user()->hasRole('panel_user_presencial')) {
return $query->where('modality', '=','P')->Orwhere('modality', '=', 'M')->Orwhere('modality', '=', 'AV');
}
})

I have observed that the id of the record that is loaded for editing is correct but the information is not.

What could be the cause of this?

Regards.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Editing Records
FilamentFFilament / ❓┊help
10mo ago
Deleting filtered records fails
FilamentFFilament / ❓┊help
14mo ago
problem when editing or viewing deleted records
FilamentFFilament / ❓┊help
3y ago
Update pivot table when editing record
FilamentFFilament / ❓┊help
2y ago