- DB: users.username (unique), users.preferred_locale (default from app.locale) - Backend: validation, model fillable; share supportedLocales; SetLocaleFromUser - Frontend: profile page fields + types - Filament: SuperAdmin profile page with username/language feat(admin-nav): move Tasks to Bibliothek and add menu labels fix(tasks-table): show localized title/emotion/event type; add translated headers feat(l10n): add missing table headers for emotions and event types; normalize en/de files refactor: tidy translations for tasks/emotions/event types
121 lines
4.6 KiB
PHP
121 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\EventResource\Pages;
|
|
use App\Models\Event;
|
|
use App\Models\Tenant;
|
|
use App\Models\EventType;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
use Filament\Actions;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\DatePicker;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Forms\Components\KeyValue;
|
|
use UnitEnum;
|
|
use BackedEnum;
|
|
|
|
class EventResource extends Resource
|
|
{
|
|
protected static ?string $model = Event::class;
|
|
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-calendar';
|
|
protected static UnitEnum|string|null $navigationGroup = null;
|
|
|
|
public static function getNavigationGroup(): UnitEnum|string|null
|
|
{
|
|
return __('admin.nav.platform');
|
|
}
|
|
protected static ?int $navigationSort = 20;
|
|
|
|
public static function form(Schema $form): Schema
|
|
{
|
|
return $form->schema([
|
|
Select::make('tenant_id')
|
|
->label(__('admin.events.fields.tenant'))
|
|
->options(Tenant::all()->pluck('name', 'id'))
|
|
->searchable()
|
|
->required(),
|
|
TextInput::make('name')
|
|
->label(__('admin.events.fields.name'))
|
|
->required()
|
|
->maxLength(255),
|
|
TextInput::make('slug')
|
|
->label(__('admin.events.fields.slug'))
|
|
->required()
|
|
->unique(ignoreRecord: true)
|
|
->maxLength(255),
|
|
DatePicker::make('date')
|
|
->label(__('admin.events.fields.date'))
|
|
->required(),
|
|
Select::make('event_type_id')
|
|
->label(__('admin.events.fields.type'))
|
|
->options(EventType::all()->pluck('name', 'id'))
|
|
->searchable(),
|
|
TextInput::make('default_locale')
|
|
->label(__('admin.events.fields.default_locale'))
|
|
->default('de')
|
|
->maxLength(5),
|
|
Toggle::make('is_active')
|
|
->label(__('admin.events.fields.is_active'))
|
|
->default(true),
|
|
KeyValue::make('settings')
|
|
->label(__('admin.events.fields.settings'))
|
|
->keyLabel(__('admin.common.key'))
|
|
->valueLabel(__('admin.common.value')),
|
|
])->columns(2);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('id')->sortable(),
|
|
Tables\Columns\TextColumn::make('tenant_id')->label(__('admin.events.table.tenant'))->sortable(),
|
|
Tables\Columns\TextColumn::make('name')->limit(30),
|
|
Tables\Columns\TextColumn::make('slug')->searchable(),
|
|
Tables\Columns\TextColumn::make('date')->date(),
|
|
Tables\Columns\IconColumn::make('is_active')->boolean(),
|
|
Tables\Columns\TextColumn::make('default_locale'),
|
|
Tables\Columns\TextColumn::make('join')->label(__('admin.events.table.join'))
|
|
->getStateUsing(fn($record) => url("/e/{$record->slug}"))
|
|
->copyable()
|
|
->copyMessage(__('admin.events.messages.join_link_copied')),
|
|
Tables\Columns\TextColumn::make('created_at')->since(),
|
|
])
|
|
->filters([])
|
|
->actions([
|
|
Actions\EditAction::make(),
|
|
Actions\Action::make('toggle')
|
|
->label(__('admin.events.actions.toggle_active'))
|
|
->icon('heroicon-o-power')
|
|
->action(fn($record) => $record->update(['is_active' => !$record->is_active])),
|
|
Actions\Action::make('join_link')
|
|
->label(__('admin.events.actions.join_link_qr'))
|
|
->icon('heroicon-o-qr-code')
|
|
->modalHeading(__('admin.events.modal.join_link_heading'))
|
|
->modalSubmitActionLabel(__('admin.common.close'))
|
|
->modalContent(fn($record) => view('filament.events.join-link', [
|
|
'link' => url("/e/{$record->slug}"),
|
|
])),
|
|
])
|
|
->bulkActions([
|
|
Actions\DeleteBulkAction::make(),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListEvents::route('/'),
|
|
'view' => Pages\ViewEvent::route('/{record}'),
|
|
'edit' => Pages\EditEvent::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|