Frontend

/laravel-agent:filament:make

Create Filament resource, page, or widget

Overview

The /filament:make command generates Filament admin panel components including resources, pages, widgets, and relation managers. It creates a complete CRUD interface with tables, forms, and actions following Filament best practices.

Usage

/laravel-agent:filament:make [Name] [type]

Examples

# Create a full CRUD resource (default)
/laravel-agent:filament:make Products

# Create a custom page
/laravel-agent:filament:make Settings page

# Create a stats or chart widget
/laravel-agent:filament:make Revenue widget

# Create a relation manager
/laravel-agent:filament:make Orders relation

Component Types

The command supports four types of Filament components:

Type Description Use Case
resource Full CRUD resource (default) Database tables with create, read, update, delete operations
page Custom page Settings pages, dashboards, or custom admin views
widget Stats or chart widget Dashboard statistics, charts, and data visualizations
relation Relation manager Managing related records within a resource (e.g., order items)

What Gets Created

For a resource (the most common component), the command generates:

Component Location Description
Resource Class app/Filament/Resources/ Main resource class with table and form definitions
List Page app/Filament/Resources/[Name]/Pages/ List view with table, filters, and bulk actions
Create Page app/Filament/Resources/[Name]/Pages/ Form for creating new records
Edit Page app/Filament/Resources/[Name]/Pages/ Form for editing existing records

Available Features

You can request specific features when creating resources:

  • filters - Add table filters for searching and filtering data
  • bulk-actions - Enable bulk delete and custom bulk operations
  • relations - Include relation managers for related models
  • charts - Add chart widgets for data visualization

Example Output Structure

For /laravel-agent:filament:make Products:

app/Filament/
└── Resources/
    ├── ProductResource.php
    └── ProductResource/
        └── Pages/
            ├── ListProducts.php
            ├── CreateProduct.php
            └── EditProduct.php

Generated Resource Example

<?php

namespace App\Filament\Resources;

use App\Filament\Resources\ProductResource\Pages;
use App\Models\Product;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;

class ProductResource extends Resource
{
    protected static ?string $model = Product::class;

    protected static ?string $navigationIcon = 'heroicon-o-shopping-bag';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('name')
                    ->required()
                    ->maxLength(255),
                Forms\Components\Textarea::make('description')
                    ->maxLength(65535),
                Forms\Components\TextInput::make('price')
                    ->numeric()
                    ->prefix('$')
                    ->required(),
                Forms\Components\Select::make('category_id')
                    ->relationship('category', 'name')
                    ->required(),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('name')
                    ->searchable()
                    ->sortable(),
                Tables\Columns\TextColumn::make('category.name')
                    ->sortable(),
                Tables\Columns\TextColumn::make('price')
                    ->money('usd')
                    ->sortable(),
                Tables\Columns\TextColumn::make('created_at')
                    ->dateTime()
                    ->sortable(),
            ])
            ->filters([
                Tables\Filters\SelectFilter::make('category')
                    ->relationship('category', 'name'),
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
                Tables\Actions\DeleteAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\BulkActionGroup::make([
                    Tables\Actions\DeleteBulkAction::make(),
                ]),
            ]);
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListProducts::route('/'),
            'create' => Pages\CreateProduct::route('/create'),
            'edit' => Pages\EditProduct::route('/{record}/edit'),
        ];
    }
}

Best Practices

  1. Use singular names - Filament automatically pluralizes resource names
  2. Define navigation groups - Organize related resources together
  3. Add filters strategically - Include filters for commonly searched fields
  4. Use bulk actions - Enable efficient multi-record operations
  5. Leverage relation managers - Handle one-to-many and many-to-many relationships

Related Agent

This command uses the laravel-filament agent.

See Also