Skip to main content

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:
This creates a resource class and associated page classes:

Defining the model

Every resource must specify which Eloquent model it manages:
If you follow Laravel’s naming conventions, Filament will automatically detect the model. For example, UserResource will use App\Models\User.

Configuring the form

The form() method defines the form schema for creating and editing records:

Configuring the table

The table() 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’s getPages() 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:
Generate a relation manager using:
Enable global search for a resource by defining which attributes to search:
For more advanced search, override the method:

Authorization

Filament integrates with Laravel’s authorization system. Define policies to control access:
Register the policy in AuthServiceProvider:
Customize how the resource appears in navigation:

Labels

Customize the labels used throughout the resource:

Widgets

Add widgets to resource pages:
Display them on a page:

Resource clusters

Group related resources together using clusters:
Generate a cluster:

Simple resources

For simple CRUD operations on a single page, use a simple resource:
This creates a single “Manage” page instead of separate list, create, and edit pages.