### Clone and Setup Filament Issue Reproduction Template Source: https://github.com/filamentphp/filament/blob/4.x/bin/issue-reproduction-template/stubs/README.md Clone the repository for the specified Filament version, install dependencies, set up the environment, and start the development server. ```bash git clone --branch {{BRANCH_VERSION}} https://github.com/filamentphp/issue-reproduction-template.git filament-issue-reproduction cd filament-issue-reproduction composer setup php artisan serve ``` -------------------------------- ### Install Filament Tables Source: https://github.com/filamentphp/filament/blob/4.x/docs/12-components/02-table.md Check if the filament/tables package is installed. If not, follow the installation guide to set it up. ```bash composer show filament/tables ``` -------------------------------- ### Add Component Example for Screenshots Source: https://github.com/filamentphp/filament/blob/4.x/CLAUDE.md Shows how to add a component example within a Livewire component for documentation screenshots. Ensure each example has a unique `->id()` for selector targeting. ```php Group::make() ->id('myComponent') ->extraAttributes(['class' => 'p-16 max-w-2xl']) ->schema([ // Your component here ]), ``` -------------------------------- ### Provide Multiple Example Rows for CSV Import Source: https://github.com/filamentphp/filament/blob/4.x/packages/actions/docs/11-import.md Use the `examples()` method with an array to provide multiple example values for a CSV import column. ```php use Filament\Actions\Imports\ImportColumn; ImportColumn::make('sku') ->examples(['ABC123', 'DEF456']) ``` -------------------------------- ### Install Filament Forms Source: https://github.com/filamentphp/filament/blob/4.x/docs/12-components/02-form.md Check if the filament/forms package is installed. If not, follow the installation guide. ```bash composer show filament/forms ``` -------------------------------- ### Provide Single Example Row for CSV Import Source: https://github.com/filamentphp/filament/blob/4.x/packages/actions/docs/11-import.md Use the `example()` method on an `ImportColumn` to provide a single example value for a CSV import column. ```php use Filament\Actions\Imports\ImportColumn; ImportColumn::make('sku') ->example('ABC123') ``` -------------------------------- ### Install Filament with Scaffold for New Projects Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/02-installation.md Installs Filament and its frontend assets for a new Laravel project. This command also installs Livewire, Alpine.js, and Tailwind CSS, and scaffolds the necessary files. It may overwrite existing application files, so it's recommended for new projects only. ```bash php artisan filament:install --scaffold npm install npm run dev ``` -------------------------------- ### Install TipTap Highlight Extension Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/10-rich-editor.md Install the TipTap highlight extension using npm. This is a prerequisite for using the highlight functionality. ```bash npm install @tiptap/extension-highlight --save-dev ``` -------------------------------- ### Install Filament Actions Source: https://github.com/filamentphp/filament/blob/4.x/docs/12-components/02-action.md Check if the filament/actions package is installed. If not, follow the installation guide. ```bash composer show filament/actions ``` -------------------------------- ### Start Documentation App Server Source: https://github.com/filamentphp/filament/blob/4.x/CLAUDE.md Command to start the local development server for the documentation application. Ensure it runs on the default port 8000, as expected by the screenshot generation script. ```bash cd docs-assets/app && php artisan serve ``` -------------------------------- ### Install Spatie Laravel Settings Plugin Source: https://github.com/filamentphp/filament/blob/4.x/packages/spatie-laravel-settings-plugin/README.md Install the plugin using Composer. The -W flag ensures all dependencies are updated. ```bash composer require filament/spatie-laravel-settings-plugin:"^4.0" -W ``` -------------------------------- ### Run Laravel Boost Installer Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/03-ai.md Run the interactive installer for Laravel Boost and select Filament for configuration. ```bash php artisan boost:install ``` -------------------------------- ### Install Filament for Existing Projects Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/02-installation.md Installs Filament frontend assets for an existing Laravel project. This command is designed to integrate Filament without overwriting existing project files, preserving current functionality. ```bash php artisan filament:install ``` -------------------------------- ### Distributing a Panel as a Filament Plugin (PHP) Source: https://github.com/filamentphp/filament/blob/4.x/docs/11-plugins/02-panel-plugins.md Provides an example of how to create a `PanelProvider` for a Filament panel within a Laravel package. This allows users to install the plugin and gain a pre-built section of their application. ```php id('blog') ->path('blog') ->resources([ // ... ]) ->pages([ // ... ]) ->widgets([ // ... ]) ->middleware([ // ... ]) ->authMiddleware([ // ... ]); } } ``` -------------------------------- ### Override setUp() for Default Configuration in Filament Components Source: https://github.com/filamentphp/filament/blob/4.x/docs/14-upgrade-guide.md Recommends overriding the `setUp()` method for passing default configuration to instantiated objects in Filament components. This method is called after instantiation, providing a more robust alternative to overriding `make()`. ```php protected function setUp(): void { parent::setUp(); $this->label('Default label'); } ``` -------------------------------- ### Basic Export Action Setup Source: https://github.com/filamentphp/filament/blob/4.x/packages/actions/docs/12-export.md Initialize the ExportAction and specify the custom exporter class to handle the export logic. ```php use App\Filament\Exports\ProductExporter; use Filament\Actions\ExportAction; ExportAction::make() ->exporter(ProductExporter::class) ``` -------------------------------- ### Install esbuild for Compilation Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/10-rich-editor.md Install esbuild, a JavaScript bundler, to compile your custom extension files. This is necessary to prepare the JavaScript for use in the browser. ```bash npm install esbuild --save-dev ``` -------------------------------- ### Install Spatie Laravel Tags Plugin Source: https://github.com/filamentphp/filament/blob/4.x/packages/spatie-laravel-tags-plugin/README.md Install the plugin using Composer. Ensure you specify the correct version constraint. ```bash composer require filament/spatie-laravel-tags-plugin:"^4.0" -W ``` -------------------------------- ### Install Filament Panel Builder (Bash) Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/02-installation.md Installs the Filament Panel Builder using Composer and registers it with the Artisan command. Requires PHP 8.2+, Laravel v11.28+, and Tailwind CSS v4.1+. This command creates a new service provider and allows for panel creation. ```bash composer require filament/filament:"^4.0" php artisan filament:install --panels ``` -------------------------------- ### Install Filament Components with Composer Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/02-installation.md Installs various Filament PHP components using Composer. This command specifies the exact versions of the packages to be installed. It's suitable for adding Filament to an existing project or for a fresh installation. ```bash composer require filament/tables:"^4.0" filament/schemas:"^4.0" filament/forms:"^4.0" filament/infolists:"^4.0" filament/actions:"^4.0" filament/notifications:"^4.0" filament/widgets:"^4.0" ``` ```bash composer require filament/tables:"~4.0" filament/schemas:"~4.0" filament/forms:"~4.0" filament/infolists:"~4.0" filament/actions:"~4.0" filament/notifications:"~4.0" filament/widgets:"~4.0" ``` -------------------------------- ### Install TipTap Packages for esbuild Plugin Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/10-rich-editor.md Install the necessary TipTap core and ProseMirror packages as development dependencies to use with the esbuild plugin. ```bash npm install --save-dev @tiptap/core @tiptap/pm ``` -------------------------------- ### Install Laravel Boost Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/03-ai.md Install Laravel Boost as a development dependency using Composer. ```bash composer require laravel/boost --dev ``` -------------------------------- ### Install Filament Spatie Media Library Plugin Source: https://github.com/filamentphp/filament/blob/4.x/packages/spatie-laravel-media-library-plugin/README.md Installs the Filament Spatie Media Library Plugin using Composer. This command fetches the specified version of the plugin and its dependencies. ```bash composer require filament/spatie-laravel-media-library-plugin:"^4.0" -W ``` -------------------------------- ### Inject Multiple Utilities into Function Source: https://github.com/filamentphp/filament/blob/4.x/packages/tables/docs/02-columns/01-overview.md Example of injecting multiple utilities (Livewire component, state, record) into a configuration function using reflection. ```php use App\Models\User; use Livewire\Component as Livewire; function (Livewire $livewire, mixed $state, User $record) { // ... } ``` -------------------------------- ### Check Filament Schemas Installation Source: https://github.com/filamentphp/filament/blob/4.x/docs/12-components/02-schema.md Verify if the filament/schemas package is installed in your project. ```bash composer show filament/schemas ``` -------------------------------- ### Install Filament Panel Builder for Windows PowerShell (Bash) Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/02-installation.md Installs the Filament Panel Builder using Composer with a version constraint suitable for Windows PowerShell, followed by Artisan registration. This is a workaround for PowerShell's handling of version characters. Requires PHP 8.2+, Laravel v11.28+, and Tailwind CSS v4.1+. ```bash composer require filament/filament:"~4.0" php artisan filament:install --panels ``` -------------------------------- ### Install InterNACHI/Modular Package Source: https://github.com/filamentphp/filament/blob/4.x/docs/09-advanced/05-modular-architecture.md Installs the InterNACHI/Modular package using Composer. This is the first step to enabling a modular architecture in your Laravel application. ```bash composer require internachi/modular ``` -------------------------------- ### Install Filament Blueprint Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/03-ai.md Install Filament Blueprint using Composer. Ensure you have purchased a license and configured your Composer repository and authentication. This command adds Blueprint as a development dependency. ```bash composer config repositories.filament composer https://packages.filamentphp.com/composer composer config --auth http-basic.packages.filamentphp.com "YOUR_EMAIL_ADDRESS" "YOUR_LICENSE_KEY" composer require filament/blueprint --dev ``` -------------------------------- ### Publish Filament Configuration File Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/02-installation.md Publishes the Filament configuration file to your project. This allows for customization of default settings across Filament packages. ```bash php artisan vendor:publish --tag=filament-config ``` -------------------------------- ### Install Phiki dependency Source: https://github.com/filamentphp/filament/blob/4.x/packages/infolists/docs/06-code-entry.md The CodeEntry component requires the Phiki package to be installed via Composer to provide syntax highlighting capabilities. ```bash composer require phiki/phiki ``` -------------------------------- ### Inject Multiple Utilities Source: https://github.com/filamentphp/filament/blob/4.x/packages/schemas/docs/01-overview.md Combine multiple utility parameters like Get and Set dynamically using reflection. No specific order is required. ```php use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Set; use Livewire\Component as Livewire; function (Livewire $livewire, Get $get, Set $set) { // ... } ``` -------------------------------- ### Align Content to Start After Infolist Entry Label Source: https://github.com/filamentphp/filament/blob/4.x/packages/infolists/docs/01-overview.md To align content added with `afterLabel()` to the start of the container instead of the default end, wrap the content within `Schema::start()`. This is useful for specific layout requirements. ```php use Filament\Infolists\Components\TextEntry; use Filament\Schemas\Components\Icon; use Filament\Schemas\Schema; use Filament\Support\Icons\Heroicon; TextEntry::make('name') ->afterLabel(Schema::start([ Icon::make(Heroicon::Star), 'This is the content after the entry\'s label' ])) ``` -------------------------------- ### Install Filament v4 Core (PowerShell) Source: https://github.com/filamentphp/filament/blob/4.x/docs/14-upgrade-guide.md Installs the main Filament v4 package after running the upgrade script in PowerShell. Uses '~4.0' for version constraints. ```powershell composer require filament/filament:"~4.0" -W --no-update ``` -------------------------------- ### Accessing Parent Field Value in Repeater Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/12-repeater.md Use `../` syntax with `$get()` to access fields outside the current repeater item. For example, `$get('../../client_id')` accesses a field two levels up. ```php $get('../../client_id') ``` -------------------------------- ### Install Filament v4 Core (Composer) Source: https://github.com/filamentphp/filament/blob/4.x/docs/14-upgrade-guide.md Installs the main Filament v4 package after running the upgrade script. This command is run without updating dependencies initially, followed by a general composer update. ```bash composer require filament/filament:"^4.0" -W --no-update ``` -------------------------------- ### Customize CSV Header for Import Column Source: https://github.com/filamentphp/filament/blob/4.x/packages/actions/docs/11-import.md Use the `exampleHeader()` method to customize the column header text in the example CSV file. ```php use Filament\Actions\Imports\ImportColumn; ImportColumn::make('sku') ->exampleHeader('SKU') ``` -------------------------------- ### Create a basic TextEntry Source: https://github.com/filamentphp/filament/blob/4.x/packages/infolists/docs/02-text-entry.md Initializes a standard text display component. ```php use Filament\Infolists\Components\TextEntry; TextEntry::make('title') ``` -------------------------------- ### Install Filament Upgrade Script (PowerShell) Source: https://github.com/filamentphp/filament/blob/4.x/docs/14-upgrade-guide.md Installs the Filament upgrade script using Composer in PowerShell, using '~4.0' for version constraints due to PowerShell's handling of '^'. This is an alternative for Windows users. ```powershell composer require filament/upgrade:"~4.0" -W --dev ``` -------------------------------- ### Install Filament Upgrade Script (Composer) Source: https://github.com/filamentphp/filament/blob/4.x/docs/14-upgrade-guide.md Installs the Filament upgrade script using Composer. This command requires the '^4.0' version and is marked as a development dependency. It's the first step in the automated upgrade process. ```bash composer require filament/upgrade:"^4.0" --dev -W ``` -------------------------------- ### Aligning Infolist Entries Source: https://github.com/filamentphp/filament/blob/4.x/packages/infolists/docs/01-overview.md Demonstrates the use of `alignStart()`, `alignCenter()`, and `alignEnd()` methods for aligning entry content. `alignStart()` is the default. ```php use Filament\Infolists\Components\TextEntry; TextEntry::make('title') ->alignStart(); // This is the default alignment. TextEntry::make('title') ->alignCenter(); TextEntry::make('title') ->alignEnd(); ``` -------------------------------- ### Update Composer Dependencies Source: https://github.com/filamentphp/filament/blob/4.x/docs/14-upgrade-guide.md Updates all project dependencies after installing the Filament v4 core package. This ensures all packages are compatible with the new Filament version. ```bash composer update ``` -------------------------------- ### Configure Plugin Service Provider (PHP) Source: https://github.com/filamentphp/filament/blob/4.x/docs/11-plugins/01-getting-started.md Example of a plugin service provider extending `PackageServiceProvider` and defining the static `$name` property for plugin registration with Filament. This is used for upgrading existing plugins. ```php class MyPluginServiceProvider extends PackageServiceProvider { public static string $name = 'my-plugin'; public function configurePackage(Package $package): void { $package->name(static::$name); } } ``` -------------------------------- ### Boot Multi-Tenant Filament Panel for Testing Source: https://github.com/filamentphp/filament/blob/4.x/docs/10-testing/02-testing-resources.md Explains how to properly boot a multi-tenant Filament panel during testing. After setting the tenant and current panel, `Filament::bootCurrentPanel()` must be called to ensure tenant scopes and model event listeners are applied correctly for accurate testing. ```php use Filament\Facades\Filament; $team = Team::factory()->create(); Filament::setTenant($this->team); Filament::setCurrentPanel('admin'); Filament::bootCurrentPanel(); ``` -------------------------------- ### Dynamically Update Select Options from Eloquent Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/01-overview.md Load select field options dynamically from an Eloquent model based on another field's selection. Use the `$get()` utility within the `options()` function to filter query results. This example fetches subcategories based on a selected category. ```php use Filament\Schemas\Components\Utilities\Get; use Filament\Forms\Components\Select; use Illuminate\Support\Collection; Select::make('category') ->options(Category::query()->pluck('name', 'id')) ->live() Select::make('sub_category') ->options(fn (Get $get): Collection => SubCategory::query() ->where('category', $get('category')) ->pluck('name', 'id')) ``` -------------------------------- ### Use Heading Component in Filament (PHP) Source: https://github.com/filamentphp/filament/blob/4.x/docs/11-plugins/04-building-a-standalone-plugin.md Demonstrates how to instantiate and configure the Heading component within a FilamentPHP project. It shows setting the heading level, content, and color using static methods and fluent setters. This example is typically placed in a README or usage guide. ```php use Awcodes\Headings\Heading; Heading::make(2) ->content('Product Information') ->color(Color::Lime), ``` -------------------------------- ### Generate Filament Theme (Bash) Source: https://github.com/filamentphp/filament/blob/4.x/docs/08-styling/01-overview.md This command generates a custom theme for a Filament panel. It installs necessary Tailwind CSS dependencies, creates a theme CSS file, and attempts to automatically configure Vite and the panel provider. This is the starting point for creating a custom visual theme for your panel. ```bash php artisan make:filament-theme ``` -------------------------------- ### Update make() signature for Entry (Filament) Source: https://github.com/filamentphp/filament/blob/4.x/docs/14-upgrade-guide.md The `make()` method signature for `Entry` has changed to `public static function make(?string $name = null): static`. Custom classes extending `Entry` should update their `make()` method signature. It's recommended to override `getDefaultName()` for default names or `setUp()` for default configuration instead of overriding `make()`. ```php label('Custom Label'); } } ``` -------------------------------- ### All Available Lifecycle Hooks in Filament Importer Source: https://github.com/filamentphp/filament/blob/4.x/packages/actions/docs/11-import.md This example demonstrates all available lifecycle hooks within a Filament importer class. Each hook allows for specific actions at different stages of data processing, validation, filling, and saving. ```php use FilamentberoActions Imports\Importer; class ProductImporter extends Importer { // ... protected function beforeValidate(): void { // Runs before the CSV data for a row is validated. } protected function afterValidate(): void { // Runs after the CSV data for a row is validated. } protected function beforeFill(): void { // Runs before the validated CSV data for a row is filled into a model instance. } protected function afterFill(): void { // Runs after the validated CSV data for a row is filled into a model instance. } protected function beforeSave(): void { // Runs before a record is saved to the database. } protected function beforeCreate(): void { // Similar to `beforeSave()`, but only runs when creating a new record. } protected function beforeUpdate(): void { // Similar to `beforeSave()`, but only runs when updating an existing record. } protected function afterSave(): void { // Runs after a record is saved to the database. } protected function afterCreate(): void { // Similar to `afterSave()`, but only runs when creating a new record. } protected function afterUpdate(): void { // Similar to `afterSave()`, but only runs when updating an existing record. } } ``` -------------------------------- ### Install Filament Notifications Package Source: https://github.com/filamentphp/filament/blob/4.x/docs/12-components/02-notifications.md This command checks if the filament/notifications package is installed. If not, it provides instructions to install and configure it. ```bash composer show filament/notifications ``` -------------------------------- ### Global Entry Configuration Source: https://github.com/filamentphp/filament/blob/4.x/packages/infolists/docs/01-overview.md Demonstrates setting default configurations for all entries of a specific type globally using `configureUsing()` in a service provider's boot method. ```php use Filament\Infolists\Components\TextEntry; TextEntry::configureUsing(function (TextEntry $entry): void { $entry->words(10); }); ``` -------------------------------- ### Update make() signature for Field, MorphToSelect, Placeholder, Builder\Block (Filament) Source: https://github.com/filamentphp/filament/blob/4.x/docs/14-upgrade-guide.md The `make()` method signature for `Field`, `MorphToSelect`, `Placeholder`, and `Builder\Block` has changed to `public static function make(?string $name = null): static`. Custom classes extending these should update their `make()` method signature. Consider overriding `getDefaultName()` for default names or `setUp()` for default configuration. ```php label('Custom Label'); } } ``` -------------------------------- ### Example Usage of Utility Injection (PHP) Source: https://github.com/filamentphp/filament/blob/4.x/packages/infolists/docs/09-custom-entries.md Demonstrates how to use the configured speed method, passing a Closure that injects the Conference utility to conditionally set the playback speed. ```php use App\Filament\Infolists\Components\AudioPlayerEntry; AudioPlayerEntry::make('recording') ->speed(fn (Conference $record): float => $record->isGlobal() ? 1 : 0.5) ``` -------------------------------- ### Basic Live Component Rendering Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/01-overview.md This example shows a basic reactive component where changes in one field trigger a full schema re-render. Use this when multiple fields depend on the updated field's state. ```php use Filament\Forms\Components\TextInput; use Filament\Schemas\Components\Utilities\Get; TextInput::make('name') ->live() TextInput::make('email') ->label(fn (Get $get): string => filled($get('name')) ? "Email address for {$get('name')}" : 'Email address') ``` -------------------------------- ### Initialize ReplicateAction Source: https://github.com/filamentphp/filament/blob/4.x/packages/actions/docs/08-replicate.md Basic implementation of the ReplicateAction. ```php use Filament\Actions\ReplicateAction; ReplicateAction::make() ``` -------------------------------- ### Configuring TextEntry with Functions Source: https://github.com/filamentphp/filament/blob/4.x/packages/infolists/docs/01-overview.md Demonstrates using functions to dynamically set labels and states for TextEntry components. Also shows conditional hiding based on record data. ```php use App\Models\User; use Filament\Infolists\Components\TextEntry; TextEntry::make('name') ->label(fn (string $state): string => str_contains($state, ' ') ? 'Full name' : 'Name') TextEntry::make('currentUserEmail') ->state(fn (): string => auth()->user()->email) TextEntry::make('role') ->hidden(fn (User $record): bool => $record->role === 'admin') ``` -------------------------------- ### Install Filament Spark Billing Provider Source: https://github.com/filamentphp/filament/blob/4.x/docs/07-users/03-tenancy.md Installs the Filament integration for Laravel Spark billing. This command-line instruction adds the necessary package to your project. Requires Composer and Laravel Spark installation. ```bash composer require filament/spark-billing-provider ``` -------------------------------- ### Enable Tenant Menu Search Source: https://github.com/filamentphp/filament/blob/4.x/docs/07-users/03-tenancy.md Configures the tenant menu to allow searching through available tenants, which is useful for panels with many tenants. ```php use Filament\Panel; public function panel(Panel $panel): Panel { return $panel // ... ->searchableTenantMenu(); } ``` -------------------------------- ### Install Tailwind CSS and Vite Plugin Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/02-installation.md Installs Tailwind CSS and its Vite plugin as development dependencies. This command is used to set up or update Tailwind CSS in a project that utilizes Vite for asset compilation. ```bash npm install tailwindcss @tailwindcss/vite --save-dev ``` -------------------------------- ### Configure tenant menu visibility and behavior Source: https://github.com/filamentphp/filament/blob/4.x/docs/07-users/03-tenancy.md Shows how to conditionally hide menu items, send POST requests from actions, disable the tenant switcher, or hide the tenant menu entirely. ```php use Filament\Actions\Action; use Filament\Panel; // Conditionally hide items Action::make('settings') ->visible(fn (): bool => auth()->user()->can('manage-team')); // Send POST request Action::make('lockSession') ->url(fn (): string => route('lock-session')) ->postToUrl(); // Disable switcher or menu in panel config public function panel(Panel $panel): Panel { return $panel ->tenantSwitcher(false) ->tenantMenu(false); } ``` -------------------------------- ### Use Prime Components in a Schema Source: https://github.com/filamentphp/filament/blob/4.x/packages/schemas/docs/08-primes.md Example demonstrating the use of Text, Image, Section, and UnorderedList prime components to display instructions, a QR code, and recovery codes within a schema. ```php use Filament\Actions\Action; use Filament\Schemas\Components\Image; use Filament\Schemas\Components\Section; use Filament\Schemas\Components\Text; use Filament\Schemas\Components\UnorderedList; use Filament\Support\Enums\FontWeight; use Filament\Support\Enums\TextSize; $schema ->components([ Text::make('Scan this QR code with your authenticator app:') ->color('neutral'), Image::make( url: asset('images/qr.jpg'), alt: 'QR code to scan with an authenticator app', ) ->imageHeight('12rem') ->alignCenter(), Section::make() ->schema([ Text::make('Please save the following recovery codes in a safe place. They will only be shown once, but you\'ll need them if you lose access to your authenticator app:') ->weight(FontWeight::Bold) ->color('neutral'), UnorderedList::make(fn (): array => array_map( fn (string $recoveryCode): Text => Text::make($recoveryCode) ->copyable() ->fontFamily(FontFamily::Mono) ->size(TextSize::ExtraSmall) ->color('neutral'), ['tYRnCqNLUx-3QOLNKyDiV', 'cKok2eImKc-oWHHH4VhNe', 'C0ZstEcSSB-nrbyk2pv8z', '49EXLRQ8MI-FpWywpSDHE', 'TXjHnvkUrr-KuiVJENPmJ', 'BB574ookll-uI20yxP6oa', 'BbgScF2egu-VOfHrMtsCl', 'cO0dJYqmee-S9ubJHpRFR'], )) ->size(TextSize::ExtraSmall), ]) ->compact() ->secondary(), ]) ``` -------------------------------- ### Create an Image Component Source: https://github.com/filamentphp/filament/blob/4.x/packages/schemas/docs/08-primes.md Display images in a schema using the `Image` component. The `make()` method accepts the image URL and alt text. Both arguments can also be functions for dynamic values. ```php use Filament\Schemas\Components\Image; Image::make( url: asset('images/qr.jpg'), alt: 'QR code to scan with an authenticator app', ) ``` -------------------------------- ### Set Notification Status (PHP) Source: https://github.com/filamentphp/filament/blob/4.x/packages/notifications/docs/01-overview.md This example shows how to set a notification's status (e.g., success, warning, danger, info) using dedicated methods in PHP, which automatically applies appropriate icons and colors. ```php use Filament\Notifications\Notification; Notification::make() ->title('Saved successfully') ->success() ->send(); ``` -------------------------------- ### Configure Storage Disk, Directory, and Visibility Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/09-file-upload.md Customize the storage disk, directory, and file visibility for uploads. Useful for organizing files and managing access. ```php use Filament\Forms\Components\FileUpload; FileUpload::make('attachment') ->disk('s3') ->directory('form-attachments') ->visibility('public') ``` -------------------------------- ### Install Filament Spatie Google Fonts Plugin via Composer Source: https://github.com/filamentphp/filament/blob/4.x/packages/spatie-laravel-google-fonts-plugin/README.md This command installs the Filament Spatie Google Fonts Plugin using Composer. Ensure you have Composer installed and configured for your project. The '-W' flag ensures all dependencies are updated. ```bash composer require filament/spatie-laravel-google-fonts-plugin:"^4.0" -W ``` -------------------------------- ### Align Content to Start After Field Label Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/01-overview.md When using `afterLabel()`, wrap the content in `Schema::start()` to align it to the start of the container, instead of the default end alignment. ```php use Filament\Forms\Components\TextInput; use Filament\Schemas\Components\Icon; use Filament\Schemas\Schema; use Filament\Support\Icons\Heroicon; TextInput::make('name') ->afterLabel(Schema::start([ Icon::make(Heroicon::Star), 'This is the content after the field\'s label' ])) ``` -------------------------------- ### Customize Tenant Menu Items Source: https://github.com/filamentphp/filament/blob/4.x/docs/07-users/03-tenancy.md Adds custom actions to the tenant-switching menu and configures the registration link label. ```php use App\Filament\Pages\Settings; use Filament\Actions\Action; use Filament\Panel; public function panel(Panel $panel): Panel { return $panel ->tenantMenuItems([ Action::make('settings') ->url(fn (): string => Settings::getUrl()) ->icon('heroicon-m-cog-8-tooth'), 'register' => fn (Action $action) => $action->label('Register new team'), ]); } ``` -------------------------------- ### Create Filament User (Bash) Source: https://github.com/filamentphp/filament/blob/4.x/docs/01-introduction/02-installation.md Generates a new Filament user account for authentication within the panel. This command is run after Filament has been installed. ```bash php artisan make:filament-user ``` -------------------------------- ### Publish and Run Tag Migrations Source: https://github.com/filamentphp/filament/blob/4.x/packages/spatie-laravel-tags-plugin/README.md Publish the migration for the tags table and then run your database migrations. ```bash php artisan vendor:publish --provider="Spatie\Tags\TagsServiceProvider" --tag="tags-migrations" ``` ```bash php artisan migrate ``` -------------------------------- ### Horizontally Align Table Column Content Source: https://github.com/filamentphp/filament/blob/4.x/packages/tables/docs/02-columns/01-overview.md Align column content to the start, center, or end using dedicated methods or the Alignment enum. The default alignment is start. ```php use Filament\Tables\Columns\TextColumn; TextColumn::make('email') ->alignStart() // This is the default alignment. TextColumn::make('email') ->alignCenter() TextColumn::make('email') ->alignEnd() ``` ```php use Filament\Support\Enums\Alignment; use Filament\Tables\Columns\TextColumn; TextColumn::make('email') ->label('Email address') ->alignment(Alignment::End) ``` -------------------------------- ### Filament Component Fluent API Example Source: https://github.com/filamentphp/filament/blob/4.x/CLAUDE.md Demonstrates the fluent API pattern in Filament components, using `make()` for instantiation and chainable methods for configuration. Nullable properties have nullable setters to allow unsetting. ```php TextInput::make('name') ->label('Full name') ->icon('heroicon-o-user') // Property and setter share the same name, nullable to allow unsetting protected string | Closure | null $icon = null; public function icon(string | Closure | null $icon): static { $this->icon = $icon; return $this; } // Getter prefixed with `get`, uses `evaluate()` for `Closure` support public function getIcon(): ?string { return $this->evaluate($this->icon); } ``` -------------------------------- ### Install Chart.js Plugins via NPM Source: https://github.com/filamentphp/filament/blob/4.x/packages/widgets/docs/03-charts.md Extend chart functionality by installing third-party Chart.js plugins using the Node Package Manager. ```bash npm install chartjs-plugin-datalabels --save-dev ``` -------------------------------- ### Navigate Wizard Steps with Filament PHP Source: https://github.com/filamentphp/filament/blob/4.x/docs/10-testing/04-testing-schemas.md Demonstrates how to navigate through wizard steps in Filament PHP components using Pest. Includes methods for going to the next, previous, or a specific step, and asserting the current step. Supports specifying a schema for components with multiple forms. ```php use function Pest\Livewire\livewire; it('moves to next wizard step', function () { livewire(CreatePost::class) ->goToNextWizardStep() ->assertHasFormErrors(['title']); }); ``` ```php use function Pest\Livewire\livewire; it('moves to next wizard step', function () { livewire(CreatePost::class) ->goToPreviousWizardStep() ->assertHasFormErrors(['title']); }); ``` ```php use function Pest\Livewire\livewire; it('moves to the wizards second step', function () { livewire(CreatePost::class) ->goToWizardStep(2) ->assertWizardCurrentStep(2); }); ``` ```php use function Pest\Livewire\livewire; it('moves to next wizard step only for fooForm', function () { livewire(CreatePost::class) ->goToNextWizardStep(schema: 'fooForm') ->assertHasFormErrors(['title'], schema: 'fooForm'); }); ``` -------------------------------- ### Injecting Multiple Utilities Source: https://github.com/filamentphp/filament/blob/4.x/packages/infolists/docs/01-overview.md Illustrates combining multiple utilities like `$livewire`, `$get`, and `$record` within a single callback function. Parameters are injected dynamically using reflection. ```php use App\Models\User; use Filament\Schemas\Components\Utilities\Get; use Livewire\Component as Livewire; function (Livewire $livewire, Get $get, User $record) { // ... } ``` -------------------------------- ### Configure All Export Disks Globally Source: https://github.com/filamentphp/filament/blob/4.x/packages/actions/docs/12-export.md Set a default storage disk for all export actions by using `ExportAction::configureUsing` within a service provider's `boot` method. ```php use Filament\Actions\ExportAction; ExportAction::configureUsing(fn (ExportAction $action) => $action->fileDisk('s3')); ``` -------------------------------- ### Initialize Markdown Editor Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/11-markdown-editor.md Basic implementation of the Markdown editor component in a Filament form. ```php use Filament\Forms\Components\MarkdownEditor; MarkdownEditor::make('content') ``` -------------------------------- ### Check Filament Widgets Installation (Bash) Source: https://github.com/filamentphp/filament/blob/4.x/docs/12-components/02-widget.md A bash command to verify if the `filament/widgets` package is installed in your project. This is a prerequisite for rendering Filament widgets. ```bash composer show filament/widgets ``` -------------------------------- ### Block Preview Blade View Example Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/13-builder.md Example of a Blade view for rendering a block's preview content. Access block data using variables with the same name as the schema fields. ```blade

{{ $text ?? 'Default heading' }}

``` -------------------------------- ### Create a Basic Empty State with Icon and Footer Action - PHP Source: https://github.com/filamentphp/filament/blob/4.x/packages/schemas/docs/07-empty-states.md Demonstrates creating a basic empty state with a title, description, icon, and a footer containing an action. This is useful for guiding users when no data is present. ```php use Filament\Actions\Action; use Filament\Schemas\Components\EmptyState; use Filament\Support\Icons\Heroicon; EmptyState::make('No users yet') ->description('Get started by creating a new user.') ->icon(Heroicon::OutlinedUser) ->footer([ Action::make('createUser') ->icon(Heroicon::Plus), ]) ``` -------------------------------- ### Install esbuild for Development Source: https://github.com/filamentphp/filament/blob/4.x/docs/09-advanced/02-assets.md Installs esbuild as a development dependency using npm. esbuild is a JavaScript bundler used to compile external libraries and Alpine components into a single file. ```bash npm install esbuild --save-dev ``` -------------------------------- ### Retrieve Form Field State with $get Source: https://github.com/filamentphp/filament/blob/4.x/packages/schemas/docs/01-overview.md Access the value of another form field within a callback using the `$get` utility. This is useful for implementing conditional logic or deriving values based on other inputs. ```php use Filament\Schemas\Components\Utilities\Get; function (Get $get) { $email = $get('email'); // Store the value of the `email` entry in the `$email` variable. //... } ``` -------------------------------- ### FilamentPHP Action Wizard Implementation Source: https://github.com/filamentphp/filament/blob/4.x/packages/actions/docs/04-create.md Illustrates how to implement a multi-step wizard for FilamentPHP actions using the `steps()` method instead of `schema()`. Each step is defined using `Step` objects, which can include descriptions and schemas for form components. The `skippableSteps()` method can be used to allow users to skip steps. ```php use Filament\Actions\CreateAction; use Filament\Forms\Components\MarkdownEditor; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; use Filament\Schemas\Components\Wizard\Step; CreateAction::make() ->steps([ Step::make('Name') ->description('Give the category a unique name') ->schema([ TextInput::make('name') ->required() ->live() ->afterStateUpdated(fn ($state, callable $set) => $set('slug', Str::slug($state))), TextInput::make('slug') ->disabled() ->required() ->unique(Category::class, 'slug'), ]) ->columns(2), Step::make('Description') ->description('Add some extra details') ->schema([ MarkdownEditor::make('description'), ]), Step::make('Visibility') ->description('Control who can view it') ->schema([ Toggle::make('is_visible') ->label('Visible to customers.') ->default(true), ]), ]) ``` ```php use Filament\Actions\CreateAction; CreateAction::make() ->steps([ // ... ]) ->skippableSteps() ``` -------------------------------- ### Create TipTap Highlight Extension File Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/10-rich-editor.md Create a JavaScript file to import and configure the TipTap highlight extension. This file will be compiled and loaded by Filament. ```javascript import Highlight from '@tiptap/extension-highlight' export default Highlight.configure({ multicolor: true, }) ``` -------------------------------- ### Configure Rich Editor Toolbar and Plugins Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/10-rich-editor.md Configure the toolbar items and add plugins to the rich editor. Use HighlightRichContentPlugin for syntax highlighting. ```php use Filament\Forms\Components\RichEditor; RichEditor::make('content') ->toolbarButtons([ 'blockquote', 'bold', 'bulletList', 'italic', 'orderedList', 'redo', 'strike', 'underline', 'undo', ]) ->plugins([ HighlightRichContentPlugin::make(), ]) ``` -------------------------------- ### Access Parent Field Values in Builder Source: https://github.com/filamentphp/filament/blob/4.x/packages/forms/docs/13-builder.md Use `$get('../parent_field_name')` within a builder's schema to access values from fields outside the current builder item. `$get()` is scoped to the current builder item by default. ```php // Example of accessing a parent field value $get('../client_id') ``` -------------------------------- ### Run Database Migrations Source: https://github.com/filamentphp/filament/blob/4.x/packages/spatie-laravel-media-library-plugin/README.md Executes all pending database migrations, including the one for the Spatie Media Library. This command updates your database schema to include new tables. ```bash php artisan migrate ``` -------------------------------- ### Set Grid Column Start Position (PHP) Source: https://github.com/filamentphp/filament/blob/4.x/packages/schemas/docs/02-layouts.md Control where a component begins within a grid layout. Accepts an integer for a default start or an array for responsive breakpoints. Can also accept a function for dynamic calculation. ```php use Filament\Forms\Components\TextInput; use Filament\Schemas\Components\Grid; Grid::make() ->columns([ 'sm' => 3, 'xl' => 6, '2xl' => 8, ]) ->schema([ TextInput::make('name') ->columnStart([ 'sm' => 2, 'xl' => 3, '2xl' => 4, ]), // ... ]) ``` -------------------------------- ### Send a Notification and Get its ID Source: https://github.com/filamentphp/filament/blob/4.x/packages/notifications/docs/01-overview.md Send a persistent notification and retrieve its unique ID for later use. ```php use Filament\Notifications\Notification; $notification = Notification::make() ->title('Hello') ->persistent() ->send() $notificationId = $notification->getId() ``` -------------------------------- ### Set Notification Icon and Color (JavaScript) Source: https://github.com/filamentphp/filament/blob/4.x/packages/notifications/docs/01-overview.md Demonstrates how to set an icon and its color for a notification using JavaScript. ```javascript new FilamentNotification() .title('Saved successfully') .icon('heroicon-o-document-text') .iconColor('success') .send() ``` -------------------------------- ### Add Operator to Start of List Source: https://github.com/filamentphp/filament/blob/4.x/packages/tables/docs/03-filters/04-query-builder.md Prepend a new operator to the existing list of operators for a constraint using `unshiftOperators()`. ```php use Filament\QueryBuilder\Constraints\Operators\IsFilledOperator; use Filament\QueryBuilder\Constraints\TextConstraint; TextConstraint::make('author.name') ->unshiftOperators([ IsFilledOperator::class, ]) ``` -------------------------------- ### Define Infolist Schema Method Source: https://github.com/filamentphp/filament/blob/4.x/docs/12-components/02-infolist.md Create a method in your Livewire component to define and return the infolist schema, setting the record and components. ```php use Filament\Schemas\Schema; public function productInfolist(Schema $schema): Schema { return $schema ->record($this->product) ->components([ // ... ]); } ```