### Filament Plugin Service Provider Example Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/11-plugins/01-getting-started.md Demonstrates the structure of a Filament plugin's service provider, extending `PackageServiceProvider` and defining the static `$name` property for registration. ```php class MyPluginServiceProvider extends PackageServiceProvider { public static string $name = 'my-plugin'; public function configurePackage(Package $package): void { $package->name(static::$name); } } ``` -------------------------------- ### Install Filament v4 Core Components Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Installs the core Filament v4 packages using Composer. Ensure your minimum-stability is set to 'beta' beforehand. ```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 Filament Frontend Assets (New Project) Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Installs Filament frontend assets and scaffolds the application for a new Laravel project. This command may overwrite existing files. ```bash php artisan filament:install --scaffold npm install npm run dev ``` -------------------------------- ### Configure Plugin Script Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/11-plugins/01-getting-started.md Command to run after cloning the Filament Plugin Skeleton to configure your new plugin by answering a series of questions. ```bash php ./configure.php ``` -------------------------------- ### Install Filament Frontend Assets (Existing Project) Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Installs Filament frontend assets for an existing Laravel project. This command is safer for projects with existing configurations. ```bash php artisan filament:install ``` -------------------------------- ### Install Filament Panel Builder (PowerShell) Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md A specific command for Windows PowerShell users, as it handles version constraints differently. This installs the Filament Panel Builder and registers its service provider. ```bash composer require filament/filament:"~4.0" php artisan filament:install --panels ``` -------------------------------- ### Blade Layout File Structure Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Example of a Blade layout file (`app.blade.php`) for a Livewire application. It includes essential meta tags, title, conditional styling for x-cloak, Filament directives for styles and scripts, and Vite asset compilation. ```blade {{ config('app.name') }} @filamentStyles @vite('resources/css/app.css') {{ $slot }} @livewire('notifications') {{-- Only required if you wish to send flash notifications --}} @filamentScripts @vite('resources/js/app.js') ``` -------------------------------- ### Install Filament Panel Builder Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Installs the Filament Panel Builder package into your Laravel project. This command requires the minimum stability to be set to 'beta'. It also registers a new service provider for the panel. ```bash composer require filament/filament:"^4.0" php artisan filament:install --panels ``` -------------------------------- ### Install Tailwind CSS and Vite Plugin Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Installs Tailwind CSS and its Vite plugin as development dependencies, necessary for styling Filament components. ```bash npm install tailwindcss @tailwindcss/vite --save-dev ``` -------------------------------- ### Set Composer Minimum Stability to Beta Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Configures Composer to allow installation of beta packages. This is a prerequisite for installing Filament v4. ```bash composer config minimum-stability beta ``` -------------------------------- ### Install Filament v4 Core Components (Windows PowerShell) Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Installs the core Filament v4 packages using Composer, specifically for Windows PowerShell users who may need to adjust version constraint syntax. ```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" ``` -------------------------------- ### Filament Grid Layout Example Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/schemas/docs/02-layouts.md Demonstrates configuring a Filament Grid component with responsive column counts and defining a text input's starting column position across different breakpoints. ```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, ]), // ... ]) ``` -------------------------------- ### Install Phiki for Code Highlighting Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/06-code-entry.md Instructions on how to install the `phiki/phiki` Composer package, which is a dependency for the Filament CodeEntry component to perform server-side code highlighting. ```Bash composer require phiki/phiki ``` -------------------------------- ### Install Filament Spatie Tags Plugin Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/spatie-laravel-tags-plugin/README.md Instructions for installing the plugin using Composer and publishing/running necessary migrations. This sets up the plugin and the database schema for tags. ```bash composer require filament/spatie-laravel-tags-plugin:"^3.2" -W php artisan vendor:publish --provider="Spatie\Tags\TagsServiceProvider" --tag="tags-migrations" php artisan migrate ``` -------------------------------- ### Install Filament Spatie Settings Plugin Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/spatie-laravel-settings-plugin/README.md Installs the plugin using Composer. The `-W` flag ensures all dependencies are updated. ```bash composer require filament/spatie-laravel-settings-plugin:"^3.2" -W ``` -------------------------------- ### Configure Filament Styles in app.css Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Imports necessary Filament CSS files into your main CSS entry point (e.g., resources/css/app.css) to enable styling for various components. ```css @import 'tailwindcss'; /* Required by all components */ @import '../../vendor/filament/support/resources/css/index.css'; /* Required by actions and tables */ @import '../../vendor/filament/actions/resources/css/index.css'; /* Required by actions, forms and tables */ @import '../../vendor/filament/forms/resources/css/index.css'; /* Required by actions and infolists */ @import '../../vendor/filament/infolists/resources/css/index.css'; /* Required by notifications */ @import '../../vendor/filament/notifications/resources/css/index.css'; /* Required by actions, infolists, forms, schemas and tables */ @import '../../vendor/filament/schemas/resources/css/index.css'; /* Required by tables */ @import '../../vendor/filament/tables/resources/css/index.css'; /* Required by widgets */ @import '../../vendor/filament/widgets/resources/css/index.css'; @variant dark (&:where(.dark, .dark *)); ``` -------------------------------- ### Compile Assets with npm Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Command to compile CSS and JavaScript assets for development. This command initiates the build process managed by npm. ```bash npm run dev ``` -------------------------------- ### Install Filament Spatie Media Library Plugin Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/spatie-laravel-media-library-plugin/README.md Installs the plugin using Composer. This command adds the necessary package to your project's dependencies. ```bash composer require filament/spatie-laravel-media-library-plugin:"^3.2" -W ``` -------------------------------- ### Configure Example CSV Data Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/actions/docs/11-import.md Demonstrates how to set example data for CSV imports, allowing users to download a pre-filled file. Supports single examples, multiple examples, and custom header names. ```php use Filament\Actions\Imports\ImportColumn; ImportColumn::make('sku') ->example('ABC123'); ``` ```php use Filament\Actions\Imports\ImportColumn; ImportColumn::make('sku') ->examples(['ABC123', 'DEF456']); ``` ```php use Filament\Actions\Imports\ImportColumn; ImportColumn::make('sku') ->exampleHeader('SKU'); ``` -------------------------------- ### Set Composer Minimum Stability Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Before installing Filament v4 (currently in beta), you must set your project's minimum stability to 'beta' in composer.json. This can be done via the command line or by manually editing the file. ```bash composer config minimum-stability beta ``` ```json { "minimum-stability": "beta" } ``` -------------------------------- ### Translation Tool: Clone, Install, and Run Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/06-contributing.md Steps to clone the Filament repository, install its dependencies, and run the translation tool to check for outdated translations. ```bash # Clone git clone git@github.com:filamentphp/filament.git # Install dependencies composer install # Run the tool ./bin/translation-tool.php ``` -------------------------------- ### Create Filament User Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Generates a new Filament user model and migration. This command is used after installing the panel builder to create an initial admin user account. ```php php artisan make:filament-user ``` -------------------------------- ### Install Filament Widgets Source: https://github.com/hasnayeen/filav4/blob/4.x/README.md Installs the Filament Widgets package, enabling the creation of real-time, reactive dashboard components using Livewire. Widgets can display charts, stats, and update live without page refreshes. ```bash composer require filament/widgets ``` -------------------------------- ### Override getDefaultName() and setUp() Instead of make() in Filament Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md This snippet illustrates the recommended approach for providing default values or initial configuration in Filament v4. It shows overriding `getDefaultName()` for default string values and `setUp()` for initial object configuration, replacing the older practice of overriding the `make()` method. ```php public static function getDefaultName(): ?string { return 'default'; } ``` ```php protected function setUp(): void { parent::setUp(); $this->label('Default label'); } ``` -------------------------------- ### Filament Schema with Prime Components Example Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/schemas/docs/06-primes.md Demonstrates building a Filament schema using various prime components. It shows how to display instructions, a QR code image, and a list of recovery codes using Text, Image, Section, and UnorderedList components. This example highlights dynamic content generation and styling options. ```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(), ]) ``` -------------------------------- ### Install Filament v4 Upgrade Script Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md Installs the Filament v4 upgrade script as a development dependency using Composer. The '-W' flag ensures all dependencies are updated, and '--dev' installs it for development purposes. ```bash composer require filament/upgrade:"^4.0" -W --dev ``` -------------------------------- ### Import Astro Component Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/02-getting-started.md Imports an Aside component from a local path within an Astro project. This component is typically used for displaying informational messages or side content. ```astro import Aside from "@components/Aside.astro" ``` -------------------------------- ### Install NPM Dependencies Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/11-plugins/04-building-a-standalone-plugin.md Command to install the development dependencies specified in `package.json`, including PostCSS and its plugins. ```bash npm install ``` -------------------------------- ### Install Filament Form Builder Source: https://github.com/hasnayeen/filav4/blob/4.x/README.md Installs the Filament Form Builder package, enabling the creation of interactive and stunning forms within Livewire components. It offers over 25 pre-built form components and is extensible for custom fields. ```bash composer require filament/forms ``` -------------------------------- ### Install TipTap Highlight Extension Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/forms/docs/10-rich-editor.md Installs the TipTap highlight extension using npm. This is a prerequisite for using the highlight functionality in the rich editor. ```bash npm install @tiptap/extension-highlight --save-dev ``` -------------------------------- ### Install Filament Infolists Source: https://github.com/hasnayeen/filav4/blob/4.x/README.md Installs the Filament Infolists package for displaying read-only information about records. It offers a flexible layout, custom component extensibility, and seamless integration with the Panel Builder. ```bash composer require filament/infolists ``` -------------------------------- ### Composer JSON Configuration for Beta Stability Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md Illustrates the composer.json file after setting the minimum stability to 'beta'. This ensures that Composer can resolve and install packages marked as beta, such as Filament v4. ```json { "minimum-stability": "beta" } ``` -------------------------------- ### PHP RichContentRenderer Setup Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/forms/docs/10-rich-editor.md Demonstrates the basic setup of the RichContentRenderer in PHP, including applying plugins. This is a foundational step for integrating custom content rendering. ```php use Filament\Support\Assets\Js; use Filament\Support\Facades\FilamentAsset; // ... RichContentRenderer::make($record->content) ->plugins([ HighlightRichContentPlugin::make(), ]) ``` -------------------------------- ### Configure Vite for Tailwind CSS Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Configures the Vite build tool to include the Tailwind CSS plugin, ensuring proper processing of Tailwind directives and CSS bundling. ```js import { defineConfig } from 'vite' import laravel from 'laravel-vite-plugin' import tailwindcss from '@tailwindcss/vite' export default defineConfig({ plugins: [ laravel({ input: ['resources/css/app.css', 'resources/js/app.js'], refresh: true, }), tailwindcss(), ], }) ``` -------------------------------- ### Install Filament Panel Builder Source: https://github.com/hasnayeen/filav4/blob/4.x/README.md Installs the core Filament Panel Builder package, which serves as the foundation for building admin panels and other full-stack applications. This package integrates other Filament components and provides a base for custom interfaces. ```bash composer require filament/filament ``` -------------------------------- ### Install Filament Table Builder Source: https://github.com/hasnayeen/filav4/blob/4.x/README.md Installs the Filament Table Builder package for crafting beautiful, optimized, and interactive datatables. It allows for easy integration into Livewire components and supports custom columns, filters, and actions. ```bash composer require filament/tables ``` -------------------------------- ### Check Filament Actions Installation (Bash) Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/12-components/02-action.md Verifies if the `filament/actions` package is installed in the project. This is a prerequisite for using Filament actions. ```bash composer show filament/actions ``` -------------------------------- ### Install Filament Actions Source: https://github.com/hasnayeen/filav4/blob/4.x/README.md Installs the Filament Actions package, which allows for the creation of buttons that can open modals for various tasks like confirmations, record editing, or data imports. Modals are built using the Form Builder. ```bash composer require filament/actions ``` -------------------------------- ### Install Filament Notifications Source: https://github.com/hasnayeen/filav4/blob/4.x/README.md Installs the Filament Notifications package, providing functionality to deliver flash notifications from Livewire requests or JavaScript. It also supports fetching and rendering notifications from the database. ```bash composer require filament/notifications ``` -------------------------------- ### Check Filament/Infolists Installation Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/12-components/02-infolist.md Verifies if the filament/infolists package is installed in your project using Composer. This is a prerequisite for using infolist features. ```bash composer show filament/infolists ``` -------------------------------- ### Install esbuild for Compilation Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/forms/docs/10-rich-editor.md Installs esbuild, a fast JavaScript bundler, which is used to compile the custom JavaScript extension file into a format suitable for the browser. ```bash npm install esbuild --save-dev ``` -------------------------------- ### Install Dependencies for Filament Plugin Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/11-plugins/03-building-a-panel-plugin.md Command to install project dependencies after updating package.json. This ensures all necessary build tools and libraries are available for the plugin development. ```bash npm install ``` -------------------------------- ### Install Filament Spatie Google Fonts Plugin Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/spatie-laravel-google-fonts-plugin/README.md Installs the Filament Spatie Google Fonts Plugin using Composer. Ensure Spatie's Laravel Google Fonts package is set up first. ```bash composer require filament/spatie-laravel-google-fonts-plugin:"^3.2" -W ``` -------------------------------- ### Install Laravel Spark Billing Provider Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/07-users/03-tenancy.md Installs the Filament integration for Laravel Spark billing. This command adds the necessary provider to your project, enabling subscription management features for tenants. ```bash composer require filament/spark-billing-provider ``` -------------------------------- ### Publish and Run Media Library Migrations Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/spatie-laravel-media-library-plugin/README.md Publishes the migration files for the Spatie Media Library and then runs all pending database migrations to create the necessary tables. ```bash php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-migrations" php artisan migrate ``` -------------------------------- ### Basic CodeEntry Setup in PHP Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/06-code-entry.md Demonstrates the fundamental usage of the Filament CodeEntry component to display a code snippet. It requires the `phiki/phiki` package for server-side highlighting and specifies the grammar for the code block. ```PHP use Filament\Infolists\Components\CodeEntry; use Phiki\Grammar\Grammar; CodeEntry::make('code') ->grammar(Grammar::Php) ``` -------------------------------- ### Check Filament Notifications Installation (Bash) Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/12-components/02-notifications.md Verifies if the `filament/notifications` package is installed using Composer. This command is essential before proceeding with notification rendering setup. ```bash composer show filament/notifications ``` -------------------------------- ### Install Filament v4 Upgrade Script (Windows PowerShell) Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md Alternative command for installing the Filament v4 upgrade script on Windows PowerShell, using '~4.0' to handle version constraints that might be ignored with '^'. ```bash composer require filament/upgrade:"~4.0" -W --dev ``` -------------------------------- ### Create Filament Resource with View Page Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/03-resources/05-viewing-records.md Demonstrates creating a new Filament resource with an integrated view page using the `--view` flag in the Artisan command. ```bash php artisan make:filament-resource User --view ``` -------------------------------- ### Create TextEntry Instance Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/01-overview.md Demonstrates how to create a basic TextEntry instance using the static `make()` method. It shows how to specify the entry's name, which typically corresponds to an Eloquent model attribute. ```php use Filament\Infolists\Components\TextEntry; TextEntry::make('title') ``` -------------------------------- ### Generate Livewire Layout Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/01-introduction/02-installation.md Generates a default Blade layout file for Livewire applications. This command creates the necessary file structure for your application's main layout. ```bash php artisan livewire:layout ``` -------------------------------- ### Defining Table Configuration in a Class Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/03-resources/01-overview.md Provides an example of a table class configuration, showing how to define columns (e.g., TextColumn), filters (e.g., Filter with query), record actions (e.g., EditAction), and toolbar actions (e.g., BulkActionGroup with DeleteBulkAction). ```php use Filament\Actions\BulkActionGroup; use Filament\Actions\DeleteBulkAction; use Filament\Actions\EditAction; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\Filter; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; public static function configure(Table $table): Table { return $table ->columns([ TextColumn::make('name'), TextColumn::make('email'), // ... ]) ->filters([ Filter::make('verified') ->query(fn (Builder $query): Builder => $query->whereNotNull('email_verified_at')), // ... ]) ->recordActions([ EditAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ]), ]); } ``` -------------------------------- ### Tailwind CSS Upgrade Command Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md Executes the official Tailwind CSS upgrade tool to automatically adjust configuration files and install necessary Tailwind v4 packages, replacing v3 dependencies. ```Bash npx @tailwindcss/upgrade ``` -------------------------------- ### Set Composer Minimum Stability to Beta Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md Configures Composer to allow beta versions of packages by setting the minimum stability to 'beta' in the composer.json file. This is a prerequisite for installing Filament v4 beta packages. ```bash composer config minimum-stability beta ``` -------------------------------- ### Filament CreateAction Wizard Steps Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/actions/docs/04-create.md Explains how to transform a Filament `CreateAction` into a multistep wizard. This is achieved by defining a `steps()` array containing `Step` objects, each with its own description and schema, allowing for a guided, multi-stage data entry process. ```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), ]), ]) ``` -------------------------------- ### Get Filament Notification ID (PHP) Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/notifications/docs/01-overview.md Provides a PHP example of how to retrieve the unique ID of a sent Filament notification. This ID is crucial for programmatically closing a specific notification later, especially when using persistent notifications. ```php use Filament\Notifications\Notification; $notification = Notification::make() ->title('Hello') ->persistent() ->send() $notificationId = $notification->getId() ``` -------------------------------- ### Set Default Active Tab (PHP) Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/schemas/docs/04-tabs.md Explains how to set which tab is active by default when the Tabs component is rendered. The `activeTab()` method accepts an integer representing the tab's index (starting from 1). This is useful for guiding users to specific content upon initial load. ```PHP use Filament\Schemas\Components\Tabs; use Filament\Schemas\Components\Tabs\Tab; Tabs::make('Tabs') ->tabs([ Tab::make('Tab 1') ->schema([ // ... ]), Tab::make('Tab 2') ->schema([ // ... ]), Tab::make('Tab 3') ->schema([ // ... ]), ]) ->activeTab(2) ``` -------------------------------- ### Enable SPA Mode Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/05-panel-configuration.md Enables Single Page Application mode for the panel, leveraging Livewire's `wire:navigate` for a smoother, faster user experience with less delay between page loads. ```php use Filament\Panel; public function panel(Panel $panel): Panel { return $panel // ... ->spa(); } ``` -------------------------------- ### Configure Default Primary Key Sorting for Filament Tables Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md Filament v4 now defaults to applying primary key sorting for tables to ensure consistent record ordering. This example shows how to disable this behavior using `defaultKeySort(false)` on a specific table. ```php use Filament\Tables\Table; public function table(Table $table): Table { return $table ->defaultKeySort(false); } ``` -------------------------------- ### Astro Component Imports Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/schemas/docs/01-overview.md Demonstrates importing Astro components used within the documentation page itself. These are for the page's structure and presentation, not Filament's UI components. ```Astro import Aside from "@components/Aside.astro" import AutoScreenshot from "@components/AutoScreenshot.astro" ``` -------------------------------- ### PHP: Update Entry::make() signature Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md The signature for the `Entry::make()` method has been updated. Any classes extending the `Entry` class and overriding `make()` must change their signature to `public static function make(?string $name = null): static`. For providing default names, override `getDefaultName()`, and for default configuration, override `setUp()`. ```PHP public static function make(?string $name = null): static // Recommended alternative for default name: public static function getDefaultName(): ?string { return 'default'; } // Recommended alternative for default configuration: protected function setUp(): void { parent::setUp(); $this->label('Default label'); } ``` -------------------------------- ### PHP: Update Column, Constraint make() signature Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md The signature for the `make()` method in `Column` and `Constraint` classes has been updated. Classes extending these base classes and overriding `make()` must adjust their signature to `public static function make(?string $name = null): static`. It is advised to use `getDefaultName()` for default names and `setUp()` for default configuration to maintain compatibility. ```PHP public static function make(?string $name = null): static // Recommended alternative for default name: public static function getDefaultName(): ?string { return 'default'; } // Recommended alternative for default configuration: protected function setUp(): void { parent::setUp(); $this->label('Default label'); } ``` -------------------------------- ### PHP: Update Field, MorphToSelect, Placeholder, Builder\Block make() signature Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/14-upgrade-guide.md The signature for the `make()` method in `Field`, `MorphToSelect`, `Placeholder`, and `Builder\Block` classes has been updated. Classes extending these base classes and overriding `make()` must adjust their signature to `public static function make(?string $name = null): static`. It is recommended to override `getDefaultName()` for default names and `setUp()` for default configuration instead of `make()`. ```PHP public static function make(?string $name = null): static // Recommended alternative for default name: public static function getDefaultName(): ?string { return 'default'; } // Recommended alternative for default configuration: protected function setUp(): void { parent::setUp(); $this->label('Default label'); } ``` -------------------------------- ### Check Filament Installation Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/12-components/02-form.md Verifies if the filament/forms package is installed in the project using Composer. This is a prerequisite for using Filament forms. ```Bash composer show filament/forms ``` -------------------------------- ### Test Page Load with assertOk() in PHP Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/10-testing/02-testing-resources.md Verifies that the Livewire create page component loads successfully, returning an HTTP 200 OK status. This is a basic check for page accessibility and component rendering. ```php use App\Filament\Resources\Users\Pages\CreateUser; use App\Models\User; it('can load the page', function () { livewire(CreateUser::class) ->assertOk(); }); ``` -------------------------------- ### Nullable Constraint Example Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/tables/docs/03-filters/04-query-builder.md Provides an example of making a TextConstraint 'nullable', which adds options to filter records where the specified field is either filled or blank. ```php use Filament\Tables\Filters\QueryBuilder\Constraints\TextConstraint; TextConstraint::make('name') ->nullable() ``` -------------------------------- ### Generate Model, Migration, Factory with Filament Resource Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/03-resources/01-overview.md Scaffolds the Eloquent model, its database migration, and factory alongside the Filament resource. This flag streamlines the initial setup process for new features by creating all related components simultaneously. ```bash php artisan make:filament-resource Customer --model --migration --factory ``` -------------------------------- ### Access Parent Field Values within Repeater using $get() Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/forms/docs/12-repeater.md Explains how to access parent field values from within a repeater's scope using the `$get()` method. By default, `$get()` is scoped to the current repeater item; use the `../` syntax to navigate up the data structure to access parent or sibling fields. ```APIDOC Accessing parent data: - `$get('field_name')`: Accesses a field within the current repeater item. - `$get('../parent_field_name')`: Accesses a field in the parent scope (e.g., outside the repeater). - `$get('')` or `$get('./')`: Returns the entire data array for the current repeater item. ``` -------------------------------- ### Configure All TextEntry Components Globally Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/01-overview.md Set default configurations for all instances of a specific entry component, like TextEntry, by using the static `configureUsing()` method in a service provider. This promotes consistency across the application. ```php use Filament\Infolists\Components\TextEntry; // In a service provider's boot() method: TextEntry::configureUsing(function (TextEntry $entry): void { $entry->words(10); }); ``` -------------------------------- ### Livewire Testing Helpers Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/10-testing/01-overview.md Filament components are mounted to Livewire components, making Livewire testing helpers essential. This section covers the primary methods for initiating tests. ```Pest livewire() // Example usage: livewire( // MyLivewireComponent::class // ) ``` ```PHPUnit Livewire::test() // Example usage: Livewire::test( // MyLivewireComponent::class // ) ``` -------------------------------- ### Check Filament Widgets Installation (Bash) Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/12-components/02-widget.md Verifies if the `filament/widgets` package is installed in your project using Composer. This is a prerequisite for using Filament widgets. ```bash composer show filament/widgets ``` -------------------------------- ### Check Filament Schemas Installation Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/12-components/02-schema.md Verifies if the `filament/schemas` package is installed in your project using Composer. This is a crucial prerequisite before proceeding with schema rendering. ```bash composer show filament/schemas ``` -------------------------------- ### Install esbuild Dependency Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/09-advanced/02-assets.md Installs esbuild as a development dependency using npm. esbuild is a fast JavaScript bundler and minifier used for compiling components. ```bash npm install esbuild --save-dev ``` -------------------------------- ### Passing Configuration to Custom Entry Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/09-custom-entries.md Shows how to instantiate a custom entry and pass configuration values to it using its public methods, such as the 'speed' method. ```php use App\Filament\Infolists\Components\AudioPlayerEntry; AudioPlayerEntry::make('recording') ->speed(0.5) ``` -------------------------------- ### PHP: Custom Entry with Utility Injection Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/09-custom-entries.md Demonstrates creating a custom Filament Infolist Entry (`AudioPlayerEntry`) that supports utility injection. It uses a `Closure` for the `speed` property and the `$this->evaluate()` method to inject utilities when the `getSpeed()` method is called. This allows dynamic configuration based on context. ```php use Closure; use Filament\Infolists\Components\Entry; class AudioPlayerEntry extends Entry { protected string $view = 'filament.infolists.components.audio-player-entry'; protected float | Closure | null $speed = null; public function speed(float | Closure | null $speed): static { $this->speed = $speed; return $this; } public function getSpeed(): ?float { return $this->evaluate($this->speed); } } ``` -------------------------------- ### Implement Wizard for Record Creation in PHP Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/03-resources/03-creating-records.md Demonstrates how to enable a multi-step wizard for record creation by adding the `HasWizard` trait to a Filament resource's page class. This transforms the standard form into a guided, step-by-step process. ```php use App\Filament\Resources\Categories\CategoryResource; use Filament\Resources\Pages\CreateRecord; class CreateCategory extends CreateRecord { use CreateRecord\Concerns\HasWizard; protected static string $resource = CategoryResource::class; protected function getSteps(): array { return [ // ... ]; } } ``` -------------------------------- ### PHP: Use Custom Entry with Utility Injection Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/09-custom-entries.md Shows how to instantiate and configure the `AudioPlayerEntry` with a closure. The closure receives a `Conference` record and returns a speed value, demonstrating utility injection by accessing the `$record` object within the configuration function. ```php use App\Filament\Infolists\Components\AudioPlayerEntry; AudioPlayerEntry::make('recording') ->speed(fn (Conference $record): float => $record->isGlobal() ? 1 : 0.5) ``` -------------------------------- ### Filament Infolist Entry: Basic Usage Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/spatie-laravel-media-library-plugin/README.md Provides the basic syntax for using the SpatieMediaLibraryImageEntry component within Filament's infolists to display media associated with a record. ```php use Filament\Infolists\Components\SpatieMediaLibraryImageEntry; SpatieMediaLibraryImageEntry::make('avatar') ``` -------------------------------- ### Set Default State for Empty Entries Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/01-overview.md Demonstrates using the `default()` method to provide an alternative state when an entry's current state is `null`. This ensures content is displayed even if the original data is missing. ```php use Filament\Infolists\Components\TextEntry; TextEntry::make('title') ->default('Untitled') ``` -------------------------------- ### Inject Other Entry/Field State using $get Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/01-overview.md Retrieve the state of another entry or form field from within a callback using the `$get` utility. This is useful for cross-field dependencies and dynamic calculations. ```php use Filament\Schemas\Components\Utilities\Get; function (Get $get) { $email = $get('email'); // Retrieves the value of the 'email' entry // ... } ``` -------------------------------- ### Cache Filament Components Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/13-deployment.md Creates cache files for Filament components (resources, pages, widgets, etc.) to speed up discovery and loading. Avoid this in local development as it prevents new components from being auto-discovered. ```bash php artisan filament:cache-components ``` -------------------------------- ### Filament Builder: Accessing Parent Field Values with `$get()` Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/forms/docs/13-builder.md Demonstrates how to use the `$get()` function to access values from parent fields within a Filament builder component. It explains the default scoping and how to use the '../' syntax to navigate up the data structure to access fields outside the current builder item. Special cases for `$get()` with no arguments or './' are also covered. ```php use Filament\Forms\Components\Builder; // Example data structure: // [ // 'client_id' => 1, // 'builder' => [ // 'item1' => [ // 'service_id' => 2, // ], // ], // ] // Inside builder.item1, to get 'client_id' (which is at the root): // $get('../client_id') would resolve to builder.client_id // $get('../../client_id') would resolve to client_id // $get() is relative to the current builder item. // $get('client_id') inside item1 looks for builder.item1.client_id. // $get('../client_id') inside item1 looks for builder.client_id. // $get('../../client_id') inside item1 looks for client_id. // $get() with no arguments, or $get('') or $get('./'), returns the full data array for the current builder item. ``` -------------------------------- ### Navigate to Next Wizard Step in Livewire Tests Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/10-testing/04-testing-schemas.md This snippet demonstrates how to advance to the next step in a Livewire wizard component during testing. It utilizes the `goToNextWizardStep()` helper provided by the testing framework. The example asserts for form errors on the next step. ```PHP use function Pest\Livewire\livewire; it('moves to next wizard step', function () { livewire(CreatePost::class) ->goToNextWizardStep() ->assertHasFormErrors(['title']); }); ``` -------------------------------- ### Install Chart.js Plugin via NPM Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/widgets/docs/03-charts.md Installs a Chart.js plugin into the project using NPM. This command downloads the specified plugin package, making it available for use in JavaScript files. ```bash npm install chartjs-plugin-datalabels --save-dev ``` -------------------------------- ### Filament Plugin Class Implementation Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/11-plugins/02-panel-plugins.md Demonstrates a basic Filament plugin class implementing the Plugin interface. It includes methods for getting the plugin ID, registering panel resources and pages, and a boot method for post-registration logic. ```php resources([ PostResource::class, CategoryResource::class, ]) ->pages([ Settings::class, ]); } public function boot(Panel $panel): void { // } } ``` -------------------------------- ### PostCSS Configuration Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/11-plugins/04-building-a-standalone-plugin.md Configuration file for PostCSS, setting up plugins like `postcss-nesting` and `cssnano` for processing CSS. ```js module.exports = { plugins: [ require('postcss-nesting')(), require('cssnano')({ preset: 'default', }), ], }; ``` -------------------------------- ### Check Filament Tables Installation Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/12-components/02-table.md Verifies if the `filament/tables` package is installed in your project using Composer. This is a crucial first step to ensure all necessary dependencies are met before proceeding with table rendering. ```bash composer show filament/tables ``` -------------------------------- ### Add Placeholder Text for Empty Entries Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/infolists/docs/01-overview.md Shows how to use the `placeholder()` method to display styled placeholder text when an entry is empty. Unlike `default()`, this is always text and not treated as actual state. ```php use Filament\Infolists\Components\TextEntry; TextEntry::make('title') ->placeholder('Untitled') ``` -------------------------------- ### Add Step Description Source: https://github.com/hasnayeen/filav4/blob/4.x/packages/schemas/docs/05-wizards.md Demonstrates adding a descriptive text below the title for each step in a Filament Wizard using the `description()` method. This can enhance clarity and provide context for each stage. ```PHP use Filament\Schemas\Components\Wizard\Step; Step::make('Order') ->description('Review your basket') ->schema([ // ... ]) ``` -------------------------------- ### Create Filament Resource Source: https://github.com/hasnayeen/filav4/blob/4.x/docs/03-resources/01-overview.md Generates a standard Filament resource for an Eloquent model. This command creates the necessary resource class, pages, schemas, and tables, providing a foundation for CRUD interfaces. ```bash php artisan make:filament-resource Customer ```