Introduction
Resources are the primary way to manage Eloquent models in Filament. They provide a complete CRUD interface with minimal configuration, including list views, forms, and additional functionality like global search and authorization.Creating a resource
You can generate a resource using the Artisan command:Defining the model
Every resource must specify which Eloquent model it manages:UserResource will use App\Models\User.
Configuring the form
Theform() method defines the form schema for creating and editing records:
Configuring the table
Thetable() method defines the columns and actions for the list view:
Resource pages
Resources use separate page classes for different operations. The default setup includes:List page
Displays a table of all records:Create page
Provides a form for creating new records:Edit page
Provides a form for editing existing records:Registering pages
Pages are registered in the resource’sgetPages() method:
Customizing the Eloquent query
You can modify the Eloquent query used by the resource:By default,
getEloquentQuery() removes the panel’s tenancy scope. If your resource is scoped to a tenant, this behavior is automatically preserved.Relation managers
Relation managers allow you to manage related records directly from the parent resource:Global search
Enable global search for a resource by defining which attributes to search:Authorization
Filament integrates with Laravel’s authorization system. Define policies to control access:AuthServiceProvider: