### Install theme dependencies Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/08-appearance.md Install required Tailwind CSS plugins and utilities via NPM. ```bash npm install tailwindcss @tailwindcss/forms @tailwindcss/typography autoprefixer tippy.js --save-dev ``` -------------------------------- ### Set starting step for Wizard Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/04-layout.md Use startOnStep to define which step the wizard should load by default. ```php use Filament\Forms\Components\Wizard; Wizard::make([ // ... ])->startOnStep(2) ``` -------------------------------- ### Define a basic Grid layout Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/06-layout.md Sets up a grid with two columns starting from the lg breakpoint. ```php use Filament\Tables\Columns\Layout\Grid; use Filament\Tables\Columns\TextColumn; Grid::make([ 'lg' => 2, ]) ->schema([ TextColumn::make('email'), TextColumn::make('phone'), ]) ``` -------------------------------- ### Install dependencies for existing projects Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/01-installation.md Install required frontend dependencies via NPM for projects not using the automated installer. ```bash npm install alpinejs @alpinejs/focus postcss tailwindcss @tailwindcss/forms @tailwindcss/typography --save-dev ``` -------------------------------- ### Quick-start installation for new projects Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/01-installation.md These commands configure Livewire, Alpine.js, and Tailwind CSS. Note that this will overwrite existing files in your application. ```bash php artisan forms:install npm install npm run dev ``` -------------------------------- ### Install Alpine.js Collapse plugin Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/06-layout.md Install the required dependency to enable animations for collapsible content. ```bash npm install @alpinejs/collapse --save-dev ``` -------------------------------- ### Install via Composer Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/notifications/docs/01-installation.md Use Composer to add the notifications package to your project. ```bash composer require filament/notifications:"^2.0" ``` -------------------------------- ### Install dependencies via NPM Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/01-installation.md Install the required dependencies including Alpine.js, PostCSS, Tailwind CSS, and the necessary plugins. ```bash npm install alpinejs postcss tailwindcss @tailwindcss/forms @tailwindcss/typography --save-dev ``` -------------------------------- ### Install the plugin via Composer Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/spatie-laravel-media-library-plugin/docs/01-installation.md Use this command to add the plugin to your project dependencies. ```bash composer require filament/spatie-laravel-media-library-plugin:"^2.0" ``` -------------------------------- ### Install Autoprefixer for Vite Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/01-installation.md Install Autoprefixer as a development dependency when using Vite. ```bash npm install autoprefixer --save-dev ``` -------------------------------- ### Semantic week start helpers Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Convenience methods to set the week start day. ```php use Filament\Forms\Components\DateTimePicker; DateTimePicker::make('published_at')->weekStartsOnMonday() DateTimePicker::make('published_at')->weekStartsOnSunday() ``` -------------------------------- ### Authenticate in TestCase Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/10-testing.md Ensure the user is authenticated before running tests by overriding the setUp method. ```php protected function setUp(): void { parent::setUp(); $this->actingAs(User::factory()->create()); } ``` -------------------------------- ### Initialize Custom Navigation Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/05-navigation.md Use this in a ServiceProvider's boot method to disable default navigation and start building a custom sidebar. ```php use Filament\Facades\Filament; use Filament\Navigation\NavigationBuilder; Filament::navigation(function (NavigationBuilder $builder): NavigationBuilder { return $builder; }); ``` -------------------------------- ### Install doctrine/dbal for auto-generation Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/02-resources/01-getting-started.md Required dependency for automatically generating forms and tables from database columns. ```bash composer require doctrine/dbal --dev ``` -------------------------------- ### Install Filament via Composer Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/01-installation.md Use this command to install the Filament package in your Laravel project. ```bash composer require filament/filament:"^2.0" ``` -------------------------------- ### Install Filament Packages Source: https://github.com/pokmot/filament-v2/blob/2.x/README.md Use Composer to install specific Filament packages into your Laravel project. ```bash composer require filament/filament ``` ```bash composer require filament/forms ``` ```bash composer require filament/tables ``` ```bash composer require filament/notifications ``` ```bash composer require filament/spatie-laravel-media-library-plugin ``` ```bash composer require filament/spatie-laravel-settings-plugin ``` ```bash composer require filament/spatie-laravel-tags-plugin ``` ```bash composer require filament/spatie-laravel-translatable-plugin ``` -------------------------------- ### Set first day of the week Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Configure the starting day of the week for the calendar view. ```php use Filament\Forms\Components\DateTimePicker; DateTimePicker::make('published_at')->firstDayOfWeek(7) ``` -------------------------------- ### Install package via Composer Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/01-installation.md Use this command to add the table builder package to your project dependencies. ```bash composer require filament/tables:"^2.0" ``` -------------------------------- ### Install Filament Forms via Composer Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/01-installation.md Use this command to add the Filament form builder package to your existing Laravel project. ```bash composer require filament/forms:"^2.0" ``` -------------------------------- ### Listening to form events in components Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/06-advanced.md Register event listeners within the setUp() method of your component class. ```php use Filament\Forms\Components\Component; protected function setUp(): void { parent::setUp(); $this->registerListeners([ 'save' => [ function (Component $component): void { // ... }, ], ]); } ``` ```php use Filament\Forms\Components\Component; protected function setUp(): void { parent::setUp(); $this->registerListeners([ 'repeater::createItem' => [ function (Component $component, string $statePath): void { if ($component->isDisabled()) { return; } if ($statePath !== $component->getStatePath()) { return; } // ... }, ], ]); } ``` ```php use Filament\Forms\Components\Component; protected function setUp(): void { parent::setUp(); $this->registerListeners([ 'repeater::deleteItem' => [ function (Component $component, string $statePath, string $uuidToDelete): void { if ($component->isDisabled()) { return; } if ($statePath !== $component->getStatePath()) { return; } // Delete item with UUID `$uuidToDelete` }, ], ]); } ``` -------------------------------- ### Starts With Validation Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/05-validation.md Validates that the field starts with one of the provided values. ```php Field::make('name')->startsWith(['a']) ``` -------------------------------- ### Run database migrations Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/spatie-laravel-media-library-plugin/docs/01-installation.md Executes the published migration to set up the media table. ```bash php artisan migrate ``` -------------------------------- ### Doesnt start with validation Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/05-validation.md Ensures the field does not start with any of the provided values. ```php Field::make('name')->doesntStartWith(['admin']) ``` -------------------------------- ### Create Stats Overview Widget Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/04-dashboard/02-stats.md Use the artisan command to generate the widget class. ```bash php artisan make:filament-widget StatsOverview --stats-overview ``` -------------------------------- ### Create a resource with a View page Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/02-resources/05-viewing-records.md Use the --view flag when generating a new resource to include a View page. ```bash php artisan make:filament-resource User --view ``` -------------------------------- ### Publish and run migrations Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/spatie-laravel-tags-plugin/docs/01-installation.md These commands publish the necessary migration files and apply them to your database. ```bash php artisan vendor:publish --provider="Spatie\Tags\TagsServiceProvider" --tag="tags-migrations" ``` ```bash php artisan migrate ``` -------------------------------- ### Create a resource widget Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/02-resources/09-widgets.md Use the Artisan command to generate the necessary widget class and view files for a specific resource. ```bash php artisan make:filament-widget CustomerOverview --resource=CustomerResource ``` -------------------------------- ### Create columns using make Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/03-columns/01-getting-started.md Initialize columns using the static make method, supporting dot syntax for relationship accessors. ```php use Filament\Tables\Columns\TextColumn; TextColumn::make('title') TextColumn::make('author.name') ``` -------------------------------- ### Define a Wizard component Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/04-layout.md Create a multi-step wizard by passing an array of Wizard\Step components to the make method. ```php use Filament\Forms\Components\Wizard; Wizard::make([ Wizard\Step::make('Order') ->schema([ // ... ]), Wizard\Step::make('Delivery') ->schema([ // ... ]), Wizard\Step::make('Billing') ->schema([ // ... ]), ]) ``` -------------------------------- ### Initialize date and time picker components Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Basic instantiation of date and time picker fields. ```php use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\DateTimePicker; use Filament\Forms\Components\TimePicker; DateTimePicker::make('published_at') DatePicker::make('date_of_birth') TimePicker::make('alarm_at') ``` -------------------------------- ### Create a layout component Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/04-layout.md Initialize a layout component using the static make method and define its child schema. ```php use Filament\Forms\Components\Grid; Grid::make() ->schema([ // ... ]) ``` -------------------------------- ### Initialize MarkdownEditor Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Basic instantiation of the MarkdownEditor component. ```php use Filament\Forms\Components\MarkdownEditor; MarkdownEditor::make('content') ``` -------------------------------- ### Define repeater data structure Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Example data structure for a form containing a repeater field. ```php [ 'client_id' => 1, 'repeater' => [ 'item1' => [ 'service_id' => 2, ], ], ] ``` -------------------------------- ### Initialize Textarea Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Basic implementation of the Textarea component for multi-line string input. ```php use Filament\Forms\Components\Textarea; Textarea::make('description') ``` -------------------------------- ### Publish configuration Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/01-installation.md Publish the package configuration files to your application. ```bash php artisan vendor:publish --tag=filament-config ``` -------------------------------- ### Enable Database Notifications Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/notifications/docs/03-database-notifications.md Configure the database settings in the package configuration file. ```php 'database' => [ 'enabled' => true, // ... ], ``` -------------------------------- ### Create a custom widget Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/04-dashboard/01-getting-started.md Use the artisan command to scaffold a new widget class and view. ```bash php artisan make:filament-widget BlogPostsOverview ``` -------------------------------- ### Opening a URL with an Action Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/03-pages/02-actions.md Configure an action to navigate to a specific URL instead of triggering a method. ```php use Filament\Pages\Actions\Action; protected function getActions(): array { return [ Action::make('settings') ->label('Settings') ->url(route('settings')), ]; } ``` -------------------------------- ### Create Notifications Table Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/notifications/docs/03-database-notifications.md Run this command to generate the migration for the database notifications table. ```bash php artisan notifications:table ``` -------------------------------- ### Create a Table Widget Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/04-dashboard/04-tables.md Use the artisan command to generate the boilerplate for a new table widget. ```bash php artisan make:filament-widget LatestOrders --table ``` -------------------------------- ### Create a Filament user Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/01-installation.md Run this command to create a new user account for accessing the admin panel. ```bash php artisan make:filament-user ``` -------------------------------- ### Create Action with URL Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/05-actions.md Define an action that navigates to a URL, optionally opening in a new tab. ```php use App\Models\Post; use Filament\Tables\Actions\Action; Action::make('edit') ->url(fn (Post $record): string => route('posts.edit', $record)) ->openUrlInNewTab() ``` -------------------------------- ### Configure storage disk and directory Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Sets the storage disk, directory path, and visibility for uploaded files. ```php use Filament\Forms\Components\FileUpload; FileUpload::make('attachment') ->disk('s3') ->directory('form-attachments') ->visibility('private') ``` -------------------------------- ### Generate resource with a View page Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/02-resources/01-getting-started.md Includes a dedicated View page in addition to the default List, Create, and Edit pages. ```bash php artisan make:filament-resource Customer --view ``` -------------------------------- ### Configure stancl/tenancy middleware Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/02-resources/01-getting-started.md Add the tenancy initialization middleware to the Filament configuration file. ```php use Stancl\Tenancy\Middleware\InitializeTenancyByDomain; 'middleware' => [ // ... 'base' => [ // ... InitializeTenancyByDomain::class ], ], ``` -------------------------------- ### Creating multi-step wizards for actions Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/05-actions.md Use the steps method to transform an action form into a multi-step wizard interface. ```php use Filament\\Forms\\Components\\MarkdownEditor; use Filament\\Forms\\Components\\TextInput; use Filament\\Forms\\Components\\Toggle; use Filament\\Forms\\Components\\Wizard\\Step; use Filament\\Tables\\Actions\\Action; Action::make('create') ->steps([ Step::make('Name') ->description('Give the category a clear and unique name') ->schema([ TextInput::make('name') ->required() ->reactive() ->afterStateUpdated(fn ($state, callable $set) => $set('slug', Str::slug($state))), TextInput::make('slug') ->disabled() ->required() ->unique(Category::class, 'slug', fn ($record) => $record), ]), Step::make('Description') ->description('Add some extra details') ->schema([ MarkdownEditor::make('description') ->columnSpan('full'), ]), Step::make('Visibility') ->description('Control who can view it') ->schema([ Toggle::make('is_visible') ->label('Visible to customers.') ->default(true), ]), ]) ``` -------------------------------- ### Listen to the ServingFilament event Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/09-plugins.md Register event listeners for ServingFilament within the packageConfiguring method to execute logic when Filament is ready. ```php use Filament\Events\ServingFilament; use Filament\PluginServiceProvider; use Illuminate\Support\Facades\Event; use Spatie\LaravelPackageTools\Package; class ExampleServiceProvider extends PluginServiceProvider { public function configurePackage(Package $package): void { $package->name('your-package-name'); } public function packageConfiguring(Package $package): void { Event::listen(ServingFilament::class, [$this, 'registerStuff']); } protected function registerStuff(ServingFilament $event): void { // ... } } ``` -------------------------------- ### Create a chart widget via CLI Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/04-dashboard/03-charts.md Use the artisan command to generate a new chart widget class. ```bash php artisan make:filament-widget BlogPostsChart --chart ``` -------------------------------- ### Register custom scripts and styles Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/08-appearance.md Use the Filament facade in a service provider's boot method to include external or local assets. ```php use Filament\Facades\Filament; Filament::registerScripts([ asset('js/my-script.js'), ]); Filament::registerStyles([ 'https://unpkg.com/tippy.js@6/dist/tippy.css', asset('css/my-styles.css'), ]); ``` -------------------------------- ### Advanced Event Emission Methods Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/notifications/docs/02-sending-notifications.md Use emitSelf, emitUp, and emitTo to target specific components when an action is clicked. ```php Action::make('undo') ->color('secondary') ->emitSelf('undoEditingPost', [$post->id]) Action::make('undo') ->color('secondary') ->emitUp('undoEditingPost', [$post->id]) Action::make('undo') ->color('secondary') ->emitTo('another_component', 'undoEditingPost', [$post->id]) ``` ```js new NotificationAction('undo') .color('secondary') .emitSelf('undoEditingPost') new NotificationAction('undo') .color('secondary') .emitUp('undoEditingPost') new NotificationAction('undo') .color('secondary') .emitTo('another_component', 'undoEditingPost') ``` -------------------------------- ### Initialize Color picker Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Basic initialization of a Color picker component, which defaults to HEX format. ```php use Filament\Forms\Components\ColorPicker; ColorPicker::make('color') ``` -------------------------------- ### Add description to a Wizard step Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/04-layout.md Use the description method to provide additional context for a specific step. ```php use Filament\Forms\Components\Wizard; Wizard\Step::make('Order') ->description('Review your basket') ->schema([ // ... ]), ``` -------------------------------- ### Initialize a form in a Livewire component Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/02-getting-started.md Implement the HasForms interface and use the InteractsWithForms trait to initialize a form within the mount method. ```php form->fill(); } protected function getFormSchema(): array { return [ Forms\Components\TextInput::make('title') ->default('Status Update') ->required(), Forms\Components\MarkdownEditor::make('content'), ]; } public function render(): View { return view('create-post'); } } ``` -------------------------------- ### Test Create Page Rendering Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/10-testing.md Verify that the Create page for a resource renders successfully by asserting a successful HTTP response. ```php it('can render page', function () { $this->get(PostResource::getUrl('create'))->assertSuccessful(); }); ``` -------------------------------- ### Create a field Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Initialize a field using the static make method with the field name. ```php use Filament\Forms\Components\TextInput; TextInput::make('name') ``` -------------------------------- ### Publish the media library migration Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/spatie-laravel-media-library-plugin/docs/01-installation.md Publishes the necessary migration file to create the media table in your database. ```bash php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations" ``` -------------------------------- ### Configure time input steps Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Set the increment intervals for hours, minutes, and seconds. ```php use Filament\Forms\Components\DateTimePicker; DateTimePicker::make('published_at') ->hoursStep(2) ->minutesStep(15) ->secondsStep(10) ``` -------------------------------- ### Configure global column behavior Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/03-columns/01-getting-started.md Sets default behaviors for all columns or specific column types within a service provider's boot method. ```php use Filament\Tables\Columns\Column; Column::configureUsing(function (Column $column): void { $column ->toggleable() ->sortable(); }); ``` ```php use Filament\Tables\Columns\TextColumn; TextColumn::configureUsing(function (TextColumn $column): void { $column ->toggleable() ->sortable(); }); ``` -------------------------------- ### Publish translation files Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/spatie-laravel-translatable-plugin/docs/01-installation.md Use this command to publish the package's language files for customization. ```bash php artisan vendor:publish --tag=filament-spatie-laravel-translatable-plugin-translations ``` -------------------------------- ### Enable skippable wizard steps Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/02-resources/03-creating-records.md Override hasSkippableSteps to allow free navigation between wizard steps. ```php public function hasSkippableSteps(): bool { return true; } ``` -------------------------------- ### Configure postcss.config.js Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/01-installation.md Register Tailwind CSS and Autoprefixer as PostCSS plugins. ```js export default { plugins: { tailwindcss: {}, autoprefixer: {}, }, } ``` -------------------------------- ### Assert Select Column Options Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/07-testing.md Verify the available options for a select column. ```php use function Pest\Livewire\livewire; it('has the correct statuses', function () { $post = Post::factory()->create(); livewire(PostsTable::class) ->assertSelectColumnHasOptions('status', ['unpublished' => 'Unpublished', 'published' => 'Published'], $post) ->assertSelectColumnDoesNotHaveOptions('status', ['archived' => 'Archived'], $post); }); ``` -------------------------------- ### Define a responsive Grid layout Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/06-layout.md Configures different column counts for lg and 2xl breakpoints using nested components. ```php use Filament\Tables\Columns\Layout\Grid; use Filament\Tables\Columns\Layout\Stack; use Filament\Tables\Columns\TextColumn; Grid::make([ 'lg' => 2, '2xl' => 4, ]) ->schema([ Stack::make([ TextColumn::make('name'), TextColumn::make('job'), ]), TextColumn::make('email'), TextColumn::make('phone'), ]) ``` -------------------------------- ### Create a simple modal-based resource Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/02-resources/01-getting-started.md Generates a resource that manages records using modals on a single page. ```bash php artisan make:filament-resource Customer --simple ``` -------------------------------- ### Organize Options into Columns Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Use the columns method to arrange options in a grid layout. ```php use Filament\Forms\Components\CheckboxList; CheckboxList::make('technologies') ->options([ 'tailwind' => 'Tailwind CSS', 'alpine' => 'Alpine.js', 'laravel' => 'Laravel', 'livewire' => 'Laravel Livewire', ]) ->columns(2) ``` -------------------------------- ### Generate a custom layout component Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/04-layout.md Run the artisan command to scaffold a new custom layout component class. ```bash php artisan make:form-layout Wizard ``` -------------------------------- ### Initialize RichEditor Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/03-fields.md Basic implementation of the rich text editor component. ```php use Filament\Forms\Components\RichEditor; RichEditor::make('content') ``` -------------------------------- ### Configure table columns, filters, and actions Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/02-getting-started.md Define the structure and behavior of the table by implementing methods for columns, filters, actions, and bulk actions. ```php size(40) ->circular(), Tables\Columns\TextColumn::make('title'), Tables\Columns\TextColumn::make('author.name'), Tables\Columns\BadgeColumn::make('status') ->colors([ 'danger' => 'draft', 'warning' => 'reviewing', 'success' => 'published', ]), Tables\Columns\IconColumn::make('is_featured')->boolean(), ]; } protected function getTableFilters(): array { return [ Tables\Filters\Filter::make('published') ->query(fn (Builder $query): Builder => $query->where('is_published', true)), Tables\Filters\SelectFilter::make('status') ->options([ 'draft' => 'Draft', 'in_review' => 'In Review', 'approved' => 'Approved', ]), ]; } protected function getTableActions(): array { return [ Tables\Actions\Action::make('edit') ->url(fn (Post $record): string => route('posts.edit', $record)), ]; } protected function getTableBulkActions(): array { return [ Tables\Actions\BulkAction::make('delete') ->label('Delete selected') ->color('danger') ->action(function (Collection $records): void { $records->each->delete(); }) ->requiresConfirmation(), ]; } public function render(): View { return view('list-posts'); } } ``` -------------------------------- ### Create a Plugin Service Provider Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/admin/docs/09-plugins.md Extend the PluginServiceProvider class to define your package configuration. ```php use Filament\PluginServiceProvider; use Spatie\LaravelPackageTools\Package; class ExampleServiceProvider extends PluginServiceProvider { public function configurePackage(Package $package): void { $package->name('your-package-name'); } // ... } ``` -------------------------------- ### Configure fields with closures Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/06-advanced.md Use closures to provide dynamic values for field configuration methods instead of hardcoded values. ```php use App\Models\User; use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; DatePicker::make('date_of_birth') ->displayFormat(function () { if (auth()->user()->country_id === 'us') { return 'm/d/Y' } else { return 'd/m/Y' } }) Select::make('userId') ->options(function () { return User::all()->pluck('name', 'id'); }) TextInput::make('middle_name') ->required(function () { return auth()->user()->hasMiddleName(); }) ``` -------------------------------- ### Configure responsive Grid breakpoints Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/04-layout.md Defines column counts for various Tailwind breakpoints to create a fully responsive layout. ```php use Filament\Forms\Components\Grid; Grid::make([ 'default' => 1, 'sm' => 2, 'md' => 3, 'lg' => 4, 'xl' => 6, '2xl' => 8, ]) ->schema([ // ... ]) ``` ```php use Filament\Forms\Components\Grid; Grid::make([ 'sm' => 2, 'xl' => 6, ]) ->schema([ // ... ]) ``` -------------------------------- ### Create a Split layout Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/tables/docs/06-layout.md Wraps columns to allow them to stack on mobile devices. ```php use Filament\Tables\Columns\Layout\Split; use Filament\Tables\Columns\TextColumn; Split::make([ ImageColumn::make('avatar'), TextColumn::make('name'), TextColumn::make('email'), ]) ``` -------------------------------- ### Create app.blade.php layout Source: https://github.com/pokmot/filament-v2/blob/2.x/packages/forms/docs/01-installation.md Define the base layout file including necessary styles, scripts, and the notifications component. ```blade