© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
7 replies
MK

Limiting Filament Table to User-Accessible in resource

Hello! How are you? I have a resource called SchoolResource for my School model. But I need only the schools that the user has permission to view to appear in the resource table. I already have a very simple method that does this, but I don't know how to limit the filament table.

   public EloquentCollection|Collection $records;

    public function mount(): void
    {
        $this->records = auth()->user()->schools();
    }

    public static function form(Form $form): Form
    {
        return $form
            ->schema(
                [
                    //Abstracted............
                ]
            )->columns(3);
    }
   public EloquentCollection|Collection $records;

    public function mount(): void
    {
        $this->records = auth()->user()->schools();
    }

    public static function form(Form $form): Form
    {
        return $form
            ->schema(
                [
                    //Abstracted............
                ]
            )->columns(3);
    }
Solution
in the resource override the query and add a scope or a where:

    public static function getEloquentQuery(): Builder
    {
        $query = parent::getEloquentQuery()-->withGlobalScope(
            SoftDeletingScope::class,
        );

        return $query;
    }
    public static function getEloquentQuery(): Builder
    {
        $query = parent::getEloquentQuery()-->withGlobalScope(
            SoftDeletingScope::class,
        );

        return $query;
    }
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Set table to use for filament resource
FilamentFFilament / ❓┊help
16mo ago
Table in Resource
FilamentFFilament / ❓┊help
14mo ago
Filament table: related resource with traits
FilamentFFilament / ❓┊help
3y ago
Unable to edit Resource in Resource table
FilamentFFilament / ❓┊help
2y ago