© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
14 replies
H.Bilbao

doubt with getEloquentQuery

I have a resource with the following getEloquentQuery:

if (isAdmin() || isSuperAdmin()) {
    $query = parent::getEloquentQuery()
        ->withoutGlobalScopes([
            SoftDeletingScope::class,
        ]);
} else {
    $query = parent::getEloquentQuery()
        ->whereHas('customer.applicants', function ($q) {
            $q->where('user_id', auth()->user()->id)->vip();
        })
        ->orwhereBelongsTo(auth()->user(), 'requestedBy')
        ->withoutGlobalScopes([
            SoftDeletingScope::class,
        ]);

\Log::info(auth()->user()->id);
\Log::info($query->toRawSql());

return $query;
if (isAdmin() || isSuperAdmin()) {
    $query = parent::getEloquentQuery()
        ->withoutGlobalScopes([
            SoftDeletingScope::class,
        ]);
} else {
    $query = parent::getEloquentQuery()
        ->whereHas('customer.applicants', function ($q) {
            $q->where('user_id', auth()->user()->id)->vip();
        })
        ->orwhereBelongsTo(auth()->user(), 'requestedBy')
        ->withoutGlobalScopes([
            SoftDeletingScope::class,
        ]);

\Log::info(auth()->user()->id);
\Log::info($query->toRawSql());

return $query;


In the table I see everything correct, but if I enter any of them in view/edit it always shows me the same record in all of them.

Am I missing something?

Thanks
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

Doubts with getEloquentQuery()
FilamentFFilament / ❓┊help
3y ago
getEloquentQuery error with Tenant
FilamentFFilament / ❓┊help
3y ago
getEloquentQuery custom builder
FilamentFFilament / ❓┊help
3y ago
Issue with getEloquentQuery, query and Action
FilamentFFilament / ❓┊help
3y ago