### Install Filament Language Tabs Package (Bash) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Use Composer to install the Filament Language Tabs package. ```bash composer require pixelpeter/filament-language-tabs ``` -------------------------------- ### Install Spatie Translatable Package (Bash) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Install the required spatie/laravel-translatable package via Composer, which is a prerequisite for using Filament Language Tabs. ```bash composer require spatie/laravel-translatable ``` -------------------------------- ### Create Translatable Model (PHP) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Example Laravel model demonstrating the use of the spatie/laravel-translatable trait and defining translatable attributes as arrays. ```php // Models/Post.php class Post extends Model { use HasFactory, HasTranslations; public $translatable = ['headline', 'body', 'slug']; protected $casts = [ 'headline' => 'array', 'body' => 'array', 'slug' => 'array', ]; protected $guarded = ['id']; } ``` -------------------------------- ### Create Translatable Model Migration (PHP) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Example database migration for a model with translatable fields, defining JSON columns for the translatable attributes as required by spatie/laravel-translatable. ```php // database/migrations ... public function up(): void { Schema::create('posts', function (Blueprint $table) { $table->id(); $table->json('headline'); $table->json('slug'); $table->json('body'); $table->timestamps(); }); } ... ``` -------------------------------- ### Configuring Default Locales for LanguageTabs (PHP) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Shows how to configure the default languages that will be displayed as tabs in the Filament form using the default_locales array in the config/filament-language-tabs.php file. This example sets German, English, and French as the default locales. ```php // config/filament-language-tabs.php return [ 'default_locales' => ['de', 'en', 'fr'], ] ``` -------------------------------- ### Running Project Tests (Bash) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Provides the command-line instruction to execute the project's test suite using the Pest testing framework. This command runs all tests located within the vendor/bin/pest executable. ```bash ./vendor/bin/pest ``` -------------------------------- ### Publish Filament Language Tabs Views (Bash) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Optionally publish the package's views using the Artisan command. ```bash php artisan vendor:publish --tag="filament-language-tabs-views" ``` -------------------------------- ### Publish Filament Language Tabs Config (Bash) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Publish the package's configuration file using the Artisan command. ```bash php artisan vendor:publish --tag="filament-language-tabs-config" ``` -------------------------------- ### Default Filament Language Tabs Config (PHP) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md The default configuration file content, defining the default and required locales for the language tabs. ```php return [ /* |-------------------------------------------------------------------------- | Default Locales |-------------------------------------------------------------------------- | | These are the locales this package will use generate the tabs | */ 'default_locales' => ['de', 'en', 'fr'], /* |-------------------------------------------------------------------------- | Required Locales |-------------------------------------------------------------------------- | | These are the locales this package will use to set the field as required | This can be used if one translation or language is optional | */ 'required_locales' => ['de', 'en'], ]; ``` -------------------------------- ### Adding LanguageTabs Component to Filament Resource (PHP) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Demonstrates how to integrate the LanguageTabs component into a Filament resource's form schema to manage translatable fields like 'headline', 'slug', and 'body' within language-specific tabs. Requires the Pixelpeter\FilamentLanguageTabs\Forms\Components\LanguageTabs dependency. ```php // app/Filament/Resources/PostResource.php ... use Pixelpeter\FilamentLanguageTabs\Forms\Components\LanguageTabs; class PostResource extends Resource { public static function form(Form $form): Form { return $form ->schema([ Forms\Components\Grid::make(1) ->schema([ LanguageTabs::make([ Forms\Components\TextInput::make('headline')->label('headline')->required(), Forms\Components\TextInput::make('slug')->label('slug'), Forms\Components\MarkdownEditor::make('body')->label('body'), ]), ]), ]); } ``` -------------------------------- ### Configuring Required Locales for LanguageTabs (PHP) Source: https://github.com/pixelpeter/filament-language-tabs/blob/main/README.md Explains how to specify which languages require a field to be filled out, even if the field is marked as required() in the form schema. The required_locales array in config/filament-language-tabs.php overrides the default required behavior for specific languages. ```php // config/filament-language-tabs.php return [ 'required_locales' => ['de', 'en'], ] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.