99 lines
3.6 KiB
PHP
99 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\EmotionResource\Pages;
|
|
use App\Models\Emotion;
|
|
use Filament\Actions;
|
|
use Filament\Forms\Components\KeyValue;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Forms\Form;
|
|
use Filament\Forms\Components\MarkdownEditor;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Schemas\Components\Tabs as SchemaTabs;
|
|
use Filament\Schemas\Components\Tabs\Tab as SchemaTab;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use UnitEnum;
|
|
use BackedEnum;
|
|
|
|
class EmotionResource extends Resource
|
|
{
|
|
protected static ?string $model = Emotion::class;
|
|
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-face-smile';
|
|
protected static UnitEnum|string|null $navigationGroup = 'Library';
|
|
protected static ?int $navigationSort = 10;
|
|
|
|
public static function form(Schema $form): Schema
|
|
{
|
|
return $form->schema([
|
|
SchemaTabs::make('content_tabs')
|
|
->label('Content Localization')
|
|
->tabs([
|
|
SchemaTab::make('German')
|
|
->icon('heroicon-o-language')
|
|
->schema([
|
|
TextInput::make('name.de')
|
|
->label('Name (German)')
|
|
->required(),
|
|
MarkdownEditor::make('description.de')
|
|
->label('Description (German)')
|
|
->columnSpanFull(),
|
|
]),
|
|
SchemaTab::make('English')
|
|
->icon('heroicon-o-language')
|
|
->schema([
|
|
TextInput::make('name.en')
|
|
->label('Name (English)')
|
|
->required(),
|
|
MarkdownEditor::make('description.en')
|
|
->label('Description (English)')
|
|
->columnSpanFull(),
|
|
]),
|
|
])
|
|
->columnSpanFull(),
|
|
TextInput::make('icon')->label('Icon/Emoji')->maxLength(50),
|
|
TextInput::make('color')->maxLength(7)->helperText('#RRGGBB'),
|
|
TextInput::make('sort_order')->numeric()->default(0),
|
|
Toggle::make('is_active')->default(true),
|
|
Select::make('eventTypes')
|
|
->label('Event Types')
|
|
->multiple()
|
|
->searchable()
|
|
->preload()
|
|
->relationship('eventTypes', 'name'),
|
|
])->columns(2);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('id')->sortable(),
|
|
Tables\Columns\TextColumn::make('name')->searchable(),
|
|
Tables\Columns\TextColumn::make('icon'),
|
|
Tables\Columns\TextColumn::make('color'),
|
|
Tables\Columns\IconColumn::make('is_active')->boolean(),
|
|
Tables\Columns\TextColumn::make('sort_order')->sortable(),
|
|
])
|
|
->filters([])
|
|
->actions([
|
|
Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Actions\DeleteBulkAction::make(),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ManageEmotions::route('/'),
|
|
'import' => Pages\ImportEmotions::route('/import'),
|
|
];
|
|
}
|
|
}
|