Loading...
Loading...
Generate FilamentPHP v4 resources with form, table, relation managers, and actions
npx skill4agent add mwguerra/claude-code-plugins filament-resource/home/mwguerra/projects/mwguerra/claude-code-plugins/filament-specialist/skills/filament-docs/references/general/03-resources//home/mwguerra/projects/mwguerra/claude-code-plugins/filament-specialist/skills/filament-docs/references/forms//home/mwguerra/projects/mwguerra/claude-code-plugins/filament-specialist/skills/filament-docs/references/tables/# Basic resource
php artisan make:filament-resource ModelName
# With generate flag (creates form/table from model)
php artisan make:filament-resource ModelName --generate
# Soft deletes support
php artisan make:filament-resource ModelName --soft-deletes
# View page only
php artisan make:filament-resource ModelName --view
# Simple resource (modal forms instead of pages)
php artisan make:filament-resource ModelName --simpleuse Filament\Forms;
use Filament\Forms\Form;
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make('Basic Information')
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\Textarea::make('description')
->rows(3)
->columnSpanFull(),
]),
Forms\Components\Section::make('Settings')
->schema([
Forms\Components\Toggle::make('is_active')
->default(true),
Forms\Components\Select::make('status')
->options([
'draft' => 'Draft',
'published' => 'Published',
]),
]),
]);
}use Filament\Tables;
use Filament\Tables\Table;
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable()
->sortable(),
Tables\Columns\IconColumn::make('is_active')
->boolean(),
Tables\Columns\BadgeColumn::make('status')
->colors([
'warning' => 'draft',
'success' => 'published',
]),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\SelectFilter::make('status')
->options([
'draft' => 'Draft',
'published' => 'Published',
]),
Tables\Filters\TernaryFilter::make('is_active'),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}php artisan make:filament-relation-manager ResourceName RelationName column_namepublic static function getRelations(): array
{
return [
RelationManagers\CommentsRelationManager::class,
RelationManagers\TagsRelationManager::class,
];
}public static function getPages(): array
{
return [
'index' => Pages\ListModels::route('/'),
'create' => Pages\CreateModel::route('/create'),
'view' => Pages\ViewModel::route('/{record}'),
'edit' => Pages\EditModel::route('/{record}/edit'),
];
}public static function canViewAny(): bool
{
return auth()->user()->can('view_any_model');
}
public static function canCreate(): bool
{
return auth()->user()->can('create_model');
}TextInput::make()Textarea::make()RichEditor::make()MarkdownEditor::make()Select::make()Radio::make()Checkbox::make()CheckboxList::make()Toggle::make()DatePicker::make()DateTimePicker::make()TimePicker::make()FileUpload::make()SpatieMediaLibraryFileUpload::make()Select::make()->relationship()CheckboxList::make()->relationship()Repeater::make()->relationship()Section::make()Fieldset::make()Tabs::make()Grid::make()Split::make()TextColumn::make()IconColumn::make()ImageColumn::make()BadgeColumn::make()ColorColumn::make()->searchable()->sortable()->toggleable()->wrap()->limit()app/Filament/Resources/ModelResource.phpapp/Filament/Resources/ModelResource/Pages/app/Filament/Resources/ModelResource/RelationManagers/tests/Feature/Filament/ModelResourceTest.php