<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
filament / spatie-laravel-translatable-plugin example snippets
use Filament\SpatieLaravelTranslatablePlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(SpatieLaravelTranslatablePlugin::make());
}
use Filament\SpatieLaravelTranslatablePlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(
SpatieLaravelTranslatablePlugin::make()
->defaultLocales(['en', 'es']),
);
}
use Filament\Resources\Concerns\Translatable;
use Filament\Resources\Resource;
class BlogPostResource extends Resource
{
use Translatable;
// ...
}
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListBlogPosts extends ListRecords
{
use ListRecords\Concerns\Translatable;
protected function getHeaderActions(): array
{
return [
Actions\LocaleSwitcher::make(),
// ...
];
}
// ...
}
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateBlogPost extends CreateRecord
{
use CreateRecord\Concerns\Translatable;
protected function getHeaderActions(): array
{
return [
Actions\LocaleSwitcher::make(),
// ...
];
}
// ...
}
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditBlogPost extends EditRecord
{
use EditRecord\Concerns\Translatable;
protected function getHeaderActions(): array
{
return [
Actions\LocaleSwitcher::make(),
// ...
];
}
// ...
}
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewBlogPost extends ViewRecord
{
use ViewRecord\Concerns\Translatable;
protected function getHeaderActions(): array
{
return [
Actions\LocaleSwitcher::make(),
// ...
];
}
// ...
}
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;
class ManageBlogPosts extends ListRecords
{
use ManageRecords\Concerns\Translatable;
protected function getHeaderActions(): array
{
return [
Actions\LocaleSwitcher::make(),
// ...
];
}
// ...
}
use Filament\Resources\Concerns\Translatable;
use Filament\Resources\Resource;
class BlogPostResource extends Resource
{
use Translatable;
// ...
public static function getTranslatableLocales(): array
{
return ['en', 'fr'];
}
}
use Filament\Resources\RelationManagers\Concerns\Translatable;
use Filament\Resources\RelationManagers\RelationManager;
class BlogPostsRelationManager extends RelationManager
{
use Translatable;
// ...
}
use Filament\Tables;
use Filament\Tables\Table;
public function table(Table $table): Table
{
return $table
->columns([
// ...
])
->headerActions([
// ...
Tables\Actions\LocaleSwitcher::make(),
]);
}
use Filament\Resources\RelationManagers\Concerns\Translatable;
use Filament\Resources\RelationManagers\RelationManager;
use Livewire\Attributes\Reactive;
class BlogPostsRelationManager extends RelationManager
{
use Translatable;
#[Reactive]
public ?string $activeLocale = null;
// ...
}
use Filament\Resources\RelationManagers\Concerns\Translatable;
use Filament\Resources\RelationManagers\RelationManager;
class BlogPostsRelationManager extends RelationManager
{
use Translatable;
// ...
public function getTranslatableLocales(): array
{
return ['en', 'fr'];
}
}