© 2026 Hedgehog Software, LLC

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

Doubts with getEloquentQuery()

I have a question, the getNavigationBadge, counts all the unprocessed records, but without filtering by employee in case that he is not an administrator. How could I make it filter without having to add the admin condition to getNavigationBadge?

public static function getEloquentQuery(): Builder
{
    if (isAdmin()) {
        $query = parent::getEloquentQuery()
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);

    } else {
        $query = parent::getEloquentQuery()->whereBelongsTo(auth()->user(), 'employee')
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);

    return $query;
}

protected static function getNavigationBadge(): ?string
{
    return parent::getEloquentQuery()->where('is_processed', 0)->count();
}
public static function getEloquentQuery(): Builder
{
    if (isAdmin()) {
        $query = parent::getEloquentQuery()
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);

    } else {
        $query = parent::getEloquentQuery()->whereBelongsTo(auth()->user(), 'employee')
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);

    return $query;
}

protected static function getNavigationBadge(): ?string
{
    return parent::getEloquentQuery()->where('is_processed', 0)->count();
}
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

doubt with getEloquentQuery
FilamentFFilament / ❓┊help
3y ago
getEloquentQuery error with Tenant
FilamentFFilament / ❓┊help
3y ago
Doubts with summarize(Count)
FilamentFFilament / ❓┊help
2y ago
getEloquentQuery custom builder
FilamentFFilament / ❓┊help
3y ago