PHP code example of pixelpeter / filament-language-tabs
1. Go to this page and download the library: Download pixelpeter/filament-language-tabs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pixelpeter / filament-language-tabs example snippets
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
// 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'];
}
// 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();
});
}
...
// 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($form)
->schema([
Forms\Components\TextInput::make('headline')->label('headline')->