feat(profile): add username + preferred_locale; wire to Inertia + middleware

- 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
This commit is contained in:
2025-09-11 21:17:19 +02:00
parent 40aa5fc188
commit fc1e64fea3
33 changed files with 960 additions and 161 deletions

View File

@@ -0,0 +1,59 @@
<?php
namespace App\Filament\Pages;
use Filament\Auth\Pages\EditProfile as BaseEditProfile;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Component;
use Filament\Schemas\Schema;
class SuperAdminProfile extends BaseEditProfile
{
protected function getUsernameFormComponent(): Component
{
return TextInput::make('username')
->label(__('Username'))
->maxLength(32)
->unique(ignoreRecord: true);
}
protected function getPreferredLocaleFormComponent(): Component
{
$supported = collect(explode(',', (string) env('APP_SUPPORTED_LOCALES', 'de,en')))
->map(fn ($l) => trim((string) $l))
->filter()
->unique()
->values()
->all();
if (empty($supported)) {
$supported = array_values(array_unique(array_filter([
config('app.locale'),
config('app.fallback_locale'),
])));
}
$options = collect($supported)->mapWithKeys(fn ($l) => [$l => strtoupper($l)])->all();
return Select::make('preferred_locale')
->label(__('Language'))
->required()
->options($options);
}
public function form(Schema $schema): Schema
{
return $schema
->components([
$this->getNameFormComponent(),
$this->getEmailFormComponent(),
$this->getUsernameFormComponent(),
$this->getPreferredLocaleFormComponent(),
$this->getPasswordFormComponent(),
$this->getPasswordConfirmationFormComponent(),
$this->getCurrentPasswordFormComponent(),
]);
}
}

View File

@@ -24,43 +24,48 @@ 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 UnitEnum|string|null $navigationGroup = null;
public static function getNavigationGroup(): UnitEnum|string|null
{
return __('admin.nav.library');
}
protected static ?int $navigationSort = 10;
public static function form(Schema $form): Schema
{
return $form->schema([
SchemaTabs::make('content_tabs')
->label('Content Localization')
->label(__('admin.emotions.sections.content_localization'))
->tabs([
SchemaTab::make('German')
SchemaTab::make(__('admin.common.german'))
->icon('heroicon-o-language')
->schema([
TextInput::make('name.de')
->label('Name (German)')
->label(__('admin.emotions.fields.name_de'))
->required(),
MarkdownEditor::make('description.de')
->label('Description (German)')
->label(__('admin.emotions.fields.description_de'))
->columnSpanFull(),
]),
SchemaTab::make('English')
SchemaTab::make(__('admin.common.english'))
->icon('heroicon-o-language')
->schema([
TextInput::make('name.en')
->label('Name (English)')
->label(__('admin.emotions.fields.name_en'))
->required(),
MarkdownEditor::make('description.en')
->label('Description (English)')
->label(__('admin.emotions.fields.description_en'))
->columnSpanFull(),
]),
])
->columnSpanFull(),
TextInput::make('icon')->label('Icon/Emoji')->maxLength(50),
TextInput::make('icon')->label(__('admin.emotions.fields.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')
->label(__('admin.emotions.fields.event_types'))
->multiple()
->searchable()
->preload()
@@ -72,12 +77,36 @@ class EmotionResource extends Resource
{
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(),
Tables\Columns\TextColumn::make('id')
->label('#')
->sortable(),
Tables\Columns\TextColumn::make('name')
->label(__('admin.emotions.table.name'))
->getStateUsing(function ($record) {
$value = $record->name;
if (is_array($value)) {
$loc = app()->getLocale();
return $value[$loc] ?? ($value['de'] ?? ($value['en'] ?? ''));
}
return (string) $value;
})
->searchable(['name->de', 'name->en'])
->limit(60),
Tables\Columns\TextColumn::make('icon')
->label(__('admin.emotions.table.icon')),
Tables\Columns\TextColumn::make('color')
->label(__('admin.emotions.table.color')),
Tables\Columns\IconColumn::make('is_active')
->label(__('admin.emotions.table.is_active'))
->boolean(),
Tables\Columns\TextColumn::make('sort_order')
->label(__('admin.emotions.table.sort_order'))
->sortable(),
])
->filters([])
->actions([

View File

@@ -15,7 +15,7 @@ class ImportEmotions extends Page
{
protected static string $resource = EmotionResource::class;
protected string $view = 'filament.resources.emotion-resource.pages.import-emotions';
protected ?string $heading = 'Import Emotions (CSV)';
protected ?string $heading = null;
public ?string $file = null;
@@ -23,7 +23,7 @@ class ImportEmotions extends Page
{
return $form->schema([
FileUpload::make('file')
->label('CSV file')
->label(__('admin.common.csv_file'))
->acceptedFileTypes(['text/csv', 'text/plain'])
->directory('imports')
->required(),
@@ -36,7 +36,7 @@ class ImportEmotions extends Page
$path = $this->form->getState()['file'] ?? null;
if (!$path || !Storage::disk('public')->exists($path)) {
Notification::make()->danger()->title('File not found')->send();
Notification::make()->danger()->title(__('admin.notifications.file_not_found'))->send();
return;
}
@@ -45,11 +45,16 @@ class ImportEmotions extends Page
Notification::make()
->success()
->title("Imported {$ok} rows")
->body($fail ? "{$fail} failed" : null)
->title(__('admin.notifications.imported_rows', ['count' => $ok]))
->body($fail ? __('admin.notifications.failed_count', ['count' => $fail]) : null)
->send();
}
public function getHeading(): string
{
return __('admin.emotions.import.heading');
}
private function importEmotionsCsv(string $file): array
{
$handle = fopen($file, 'r');

View File

@@ -15,11 +15,11 @@ class ManageEmotions extends ManageRecords
return [
Actions\CreateAction::make(),
Actions\Action::make('import')
->label('Import CSV')
->label(__('admin.common.import_csv'))
->icon('heroicon-o-arrow-up-tray')
->url(EmotionResource::getUrl('import')),
Actions\Action::make('template')
->label('Download CSV Template')
->label(__('admin.common.download_csv_template'))
->icon('heroicon-o-document-arrow-down')
->url(url('/super-admin/templates/emotions.csv')),
];

View File

@@ -25,44 +25,49 @@ 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 = 'Platform';
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('Tenant')
->label(__('admin.events.fields.tenant'))
->options(Tenant::all()->pluck('name', 'id'))
->searchable()
->required(),
TextInput::make('name')
->label('Event Name')
->label(__('admin.events.fields.name'))
->required()
->maxLength(255),
TextInput::make('slug')
->label('Slug')
->label(__('admin.events.fields.slug'))
->required()
->unique(ignoreRecord: true)
->maxLength(255),
DatePicker::make('date')
->label('Event Date')
->label(__('admin.events.fields.date'))
->required(),
Select::make('event_type_id')
->label('Event Type')
->label(__('admin.events.fields.type'))
->options(EventType::all()->pluck('name', 'id'))
->searchable(),
TextInput::make('default_locale')
->label('Default Locale')
->label(__('admin.events.fields.default_locale'))
->default('de')
->maxLength(5),
Toggle::make('is_active')
->label('Is Active')
->label(__('admin.events.fields.is_active'))
->default(true),
KeyValue::make('settings')
->label('Settings')
->keyLabel('Key')
->valueLabel('Value'),
->label(__('admin.events.fields.settings'))
->keyLabel(__('admin.common.key'))
->valueLabel(__('admin.common.value')),
])->columns(2);
}
@@ -71,30 +76,30 @@ class EventResource extends Resource
return $table
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('tenant_id')->label('Tenant')->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('Join')
Tables\Columns\TextColumn::make('join')->label(__('admin.events.table.join'))
->getStateUsing(fn($record) => url("/e/{$record->slug}"))
->copyable()
->copyMessage('Join link copied'),
->copyMessage(__('admin.events.messages.join_link_copied')),
Tables\Columns\TextColumn::make('created_at')->since(),
])
->filters([])
->actions([
Actions\EditAction::make(),
Actions\Action::make('toggle')
->label('Toggle Active')
->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('Join Link / QR')
->label(__('admin.events.actions.join_link_qr'))
->icon('heroicon-o-qr-code')
->modalHeading('Event Join Link')
->modalSubmitActionLabel('Close')
->modalHeading(__('admin.events.modal.join_link_heading'))
->modalSubmitActionLabel(__('admin.common.close'))
->modalContent(fn($record) => view('filament.events.join-link', [
'link' => url("/e/{$record->slug}"),
])),
@@ -112,4 +117,4 @@ class EventResource extends Resource
'edit' => Pages\EditEvent::route('/{record}/edit'),
];
}
}
}

View File

@@ -21,35 +21,40 @@ class EventTypeResource extends Resource
{
protected static ?string $model = EventType::class;
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-swatch';
protected static UnitEnum|string|null $navigationGroup = 'Library';
protected static UnitEnum|string|null $navigationGroup = null;
public static function getNavigationGroup(): UnitEnum|string|null
{
return __('admin.nav.library');
}
protected static ?int $navigationSort = 20;
public static function form(Schema $form): Schema
{
return $form->schema([
SchemaTabs::make('name_tabs')
->label('Name Localization')
->label(__('admin.event_types.sections.name_localization'))
->tabs([
SchemaTab::make('German')
SchemaTab::make(__('admin.common.german'))
->icon('heroicon-o-language')
->schema([
TextInput::make('name.de')
->label('Name (German)')
->label(__('admin.event_types.fields.name_de'))
->required(),
]),
SchemaTab::make('English')
SchemaTab::make(__('admin.common.english'))
->icon('heroicon-o-language')
->schema([
TextInput::make('name.en')
->label('Name (English)')
->label(__('admin.event_types.fields.name_en'))
->required(),
]),
]),
TextInput::make('slug')->required()->unique(ignoreRecord: true),
TextInput::make('icon')->maxLength(64),
KeyValue::make('settings')->label('Settings')->keyLabel('key')->valueLabel('value'),
TextInput::make('slug')->label(__('admin.event_types.fields.slug'))->required()->unique(ignoreRecord: true),
TextInput::make('icon')->label(__('admin.event_types.fields.icon'))->maxLength(64),
KeyValue::make('settings')->label(__('admin.event_types.fields.settings'))->keyLabel(__('admin.common.key'))->valueLabel(__('admin.common.value')),
Select::make('emotions')
->label('Emotions')
->label(__('admin.event_types.fields.emotions'))
->multiple()
->searchable()
->preload()
@@ -61,11 +66,33 @@ class EventTypeResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('name')->searchable(),
Tables\Columns\TextColumn::make('slug')->searchable(),
Tables\Columns\TextColumn::make('icon'),
Tables\Columns\TextColumn::make('created_at')->since(),
Tables\Columns\TextColumn::make('id')
->label('#')
->sortable(),
Tables\Columns\TextColumn::make('name')
->label(__('admin.event_types.table.name'))
->getStateUsing(function ($record) {
$value = $record->name;
if (is_array($value)) {
$loc = app()->getLocale();
return $value[$loc] ?? ($value['de'] ?? ($value['en'] ?? ''));
}
return (string) $value;
})
->searchable(['name->de', 'name->en'])
->limit(60),
Tables\Columns\TextColumn::make('slug')
->label(__('admin.event_types.table.slug'))
->searchable(),
Tables\Columns\TextColumn::make('icon')
->label(__('admin.event_types.table.icon')),
Tables\Columns\TextColumn::make('created_at')
->label(__('admin.event_types.table.created_at'))
->since(),
])
->filters([])
->actions([
@@ -82,4 +109,4 @@ class EventTypeResource extends Resource
'index' => Pages\ManageEventTypes::route('/'),
];
}
}
}

View File

@@ -23,52 +23,57 @@ class LegalPageResource extends Resource
{
protected static ?string $model = LegalPage::class;
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-scale';
protected static UnitEnum|string|null $navigationGroup = 'Platform';
protected static UnitEnum|string|null $navigationGroup = null;
public static function getNavigationGroup(): UnitEnum|string|null
{
return __('admin.nav.platform');
}
protected static ?int $navigationSort = 40;
public static function form(Schema $form): Schema
{
return $form->schema([
TextInput::make('slug')
->label('Slug')
->label(__('admin.legal_pages.fields.slug'))
->required()
->unique(ignoreRecord: true)
->maxLength(255),
KeyValue::make('title')
->label('Title (de/en)')
->keyLabel('locale')
->valueLabel('value')
->label(__('admin.legal_pages.fields.title_localized'))
->keyLabel(__('admin.common.locale'))
->valueLabel(__('admin.common.value'))
->default(['de' => '', 'en' => ''])
->required(),
SchemaTabs::make('content_tabs')
->label('Content Localization')
->label(__('admin.legal_pages.fields.content_localization'))
->tabs([
SchemaTab::make('German')
SchemaTab::make(__('admin.common.german'))
->icon('heroicon-o-language')
->schema([
MarkdownEditor::make('body_markdown.de')
->label('Content (German)')
->label(__('admin.legal_pages.fields.content_de'))
->required()
->columnSpanFull(),
]),
SchemaTab::make('English')
SchemaTab::make(__('admin.common.english'))
->icon('heroicon-o-language')
->schema([
MarkdownEditor::make('body_markdown.en')
->label('Content (English)')
->label(__('admin.legal_pages.fields.content_en'))
->required()
->columnSpanFull(),
]),
])
->columnSpanFull(),
Toggle::make('is_published')
->label('Is Published')
->label(__('admin.legal_pages.fields.is_published'))
->default(true),
DatePicker::make('effective_from')
->label('Effective From')
->label(__('admin.legal_pages.fields.effective_from'))
->required(),
TextInput::make('version')
->label('Version')
->label(__('admin.legal_pages.fields.version'))
->required()
->default('1.0')
->maxLength(20),

View File

@@ -24,30 +24,36 @@ class PhotoResource extends Resource
{
protected static ?string $model = Photo::class;
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-photo';
protected static UnitEnum|string|null $navigationGroup = 'Content';
protected static UnitEnum|string|null $navigationGroup = null;
public static function getNavigationGroup(): UnitEnum|string|null
{
return __('admin.nav.content');
}
protected static ?int $navigationSort = 30;
public static function form(Schema $form): Schema
{
return $form->schema([
Select::make('event_id')
->label('Event')
->label(__('admin.photos.fields.event'))
->options(Event::all()->pluck('name', 'id'))
->searchable()
->required(),
FileUpload::make('image_path')
->label('Photo')
->image()
FileUpload::make('file_path')
->label(__('admin.photos.fields.photo'))
->image() // enable FilePond image preview
->disk('public')
->directory('photos')
->required()
->visibility('public'),
->visibility('public')
->required(),
Toggle::make('is_featured')
->label('Is Featured')
->label(__('admin.photos.fields.is_featured'))
->default(false),
KeyValue::make('metadata')
->label('Metadata')
->keyLabel('Key')
->valueLabel('Value'),
->label(__('admin.photos.fields.metadata'))
->keyLabel(__('admin.common.key'))
->valueLabel(__('admin.common.value')),
])->columns(2);
}
@@ -55,10 +61,10 @@ class PhotoResource extends Resource
{
return $table
->columns([
Tables\Columns\ImageColumn::make('image_path')->label('Photo')->disk('public')->visibility('public'),
Tables\Columns\ImageColumn::make('file_path')->label(__('admin.photos.table.photo'))->disk('public')->visibility('public'),
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('event_id')->label('Event'),
Tables\Columns\TextColumn::make('likes_count')->label('Likes'),
Tables\Columns\TextColumn::make('event_id')->label(__('admin.photos.table.event')),
Tables\Columns\TextColumn::make('likes_count')->label(__('admin.photos.table.likes')),
Tables\Columns\IconColumn::make('is_featured')->boolean(),
Tables\Columns\TextColumn::make('created_at')->since(),
])
@@ -66,12 +72,12 @@ class PhotoResource extends Resource
->actions([
Actions\EditAction::make(),
Actions\Action::make('feature')
->label('Feature')
->label(__('admin.photos.actions.feature'))
->visible(fn($record) => !$record->is_featured)
->action(fn($record) => $record->update(['is_featured' => true]))
->icon('heroicon-o-star'),
Actions\Action::make('unfeature')
->label('Unfeature')
->label(__('admin.photos.actions.unfeature'))
->visible(fn($record) => $record->is_featured)
->action(fn($record) => $record->update(['is_featured' => false]))
->icon('heroicon-o-star'),
@@ -79,11 +85,11 @@ class PhotoResource extends Resource
])
->bulkActions([
Actions\BulkAction::make('feature')
->label('Feature selected')
->label(__('admin.photos.actions.feature_selected'))
->icon('heroicon-o-star')
->action(fn($records) => $records->each->update(['is_featured' => true])),
Actions\BulkAction::make('unfeature')
->label('Unfeature selected')
->label(__('admin.photos.actions.unfeature_selected'))
->icon('heroicon-o-star')
->action(fn($records) => $records->each->update(['is_featured' => false])),
Actions\DeleteBulkAction::make(),
@@ -98,4 +104,4 @@ class PhotoResource extends Resource
'edit' => Pages\EditPhoto::route('/{record}/edit'),
];
}
}
}

View File

@@ -23,59 +23,69 @@ class TaskResource extends Resource
{
protected static ?string $model = Task::class;
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-clipboard-document-check';
protected static UnitEnum|string|null $navigationGroup = 'Library';
protected static UnitEnum|string|null $navigationGroup = null;
protected static ?int $navigationSort = 30;
public static function getNavigationGroup(): UnitEnum|string|null
{
return __('admin.nav.library');
}
public static function getNavigationLabel(): string
{
return __('admin.tasks.menu');
}
public static function form(Schema $form): Schema
{
return $form->schema([
Select::make('emotion_id')
->relationship('emotion', 'name')
->getOptionLabelFromRecordUsing(fn ($record) => is_array($record->name) ? ($record->name['de'] ?? $record->name['en'] ?? 'Unnamed') : $record->name)
->getOptionLabelFromRecordUsing(fn ($record) => is_array($record->name) ? ($record->name['de'] ?? $record->name['en'] ?? __('admin.common.unnamed')) : $record->name)
->required()
->searchable()
->preload(),
Select::make('event_type_id')
->relationship('eventType', 'name')
->getOptionLabelFromRecordUsing(fn ($record) => is_array($record->name) ? ($record->name['de'] ?? $record->name['en'] ?? 'Unnamed') : $record->name)
->getOptionLabelFromRecordUsing(fn ($record) => is_array($record->name) ? ($record->name['de'] ?? $record->name['en'] ?? __('admin.common.unnamed')) : $record->name)
->searchable()
->preload()
->label('Event Type (optional)'),
->label(__('admin.tasks.fields.event_type_optional')),
SchemaTabs::make('content_tabs')
->label('Content Localization')
->label(__('admin.tasks.fields.content_localization'))
->tabs([
SchemaTab::make('German')
SchemaTab::make(__('admin.common.german'))
->icon('heroicon-o-language')
->schema([
TextInput::make('title.de')
->label('Title (German)')
->label(__('admin.tasks.fields.title_de'))
->required(),
MarkdownEditor::make('description.de')
->label('Description (German)')
->label(__('admin.tasks.fields.description_de'))
->columnSpanFull(),
MarkdownEditor::make('example_text.de')
->label('Example Text (German)')
->label(__('admin.tasks.fields.example_de'))
->columnSpanFull(),
]),
SchemaTab::make('English')
SchemaTab::make(__('admin.common.english'))
->icon('heroicon-o-language')
->schema([
TextInput::make('title.en')
->label('Title (English)')
->label(__('admin.tasks.fields.title_en'))
->required(),
MarkdownEditor::make('description.en')
->label('Description (English)')
->label(__('admin.tasks.fields.description_en'))
->columnSpanFull(),
MarkdownEditor::make('example_text.en')
->label('Example Text (English)')
->label(__('admin.tasks.fields.example_en'))
->columnSpanFull(),
]),
])
->columnSpanFull(),
Select::make('difficulty')->options([
'easy' => 'Easy',
'medium' => 'Medium',
'hard' => 'Hard',
Select::make('difficulty')->label(__('admin.tasks.fields.difficulty.label'))->options([
'easy' => __('admin.tasks.fields.difficulty.easy'),
'medium' => __('admin.tasks.fields.difficulty.medium'),
'hard' => __('admin.tasks.fields.difficulty.hard'),
])->default('easy'),
TextInput::make('sort_order')->numeric()->default(0),
Toggle::make('is_active')->default(true),
@@ -86,13 +96,59 @@ class TaskResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('emotion.name')->label('Emotion')->sortable()->searchable(),
Tables\Columns\TextColumn::make('eventType.name')->label('Event Type')->toggleable(),
Tables\Columns\TextColumn::make('title')->searchable()->limit(40),
Tables\Columns\TextColumn::make('difficulty')->badge(),
Tables\Columns\IconColumn::make('is_active')->boolean(),
Tables\Columns\TextColumn::make('sort_order')->sortable(),
Tables\Columns\TextColumn::make('id')
->label('#')
->sortable(),
Tables\Columns\TextColumn::make('title')
->label(__('admin.tasks.table.title'))
->getStateUsing(function ($record) {
$value = $record->title;
if (is_array($value)) {
$loc = app()->getLocale();
return $value[$loc] ?? ($value['de'] ?? ($value['en'] ?? ''));
}
return (string) $value;
})
->limit(60)
->searchable(['title->de', 'title->en']),
Tables\Columns\TextColumn::make('emotion.name')
->label(__('admin.tasks.fields.emotion'))
->getStateUsing(function ($record) {
$value = optional($record->emotion)->name;
if (is_array($value)) {
$loc = app()->getLocale();
return $value[$loc] ?? ($value['de'] ?? ($value['en'] ?? ''));
}
return (string) ($value ?? '');
})
->sortable()
->searchable(['emotion->name->de', 'emotion->name->en']),
Tables\Columns\TextColumn::make('eventType.name')
->label(__('admin.tasks.fields.event_type'))
->getStateUsing(function ($record) {
$value = optional($record->eventType)->name;
if (is_array($value)) {
$loc = app()->getLocale();
return $value[$loc] ?? ($value['de'] ?? ($value['en'] ?? ''));
}
return (string) ($value ?? '');
})
->toggleable(),
Tables\Columns\TextColumn::make('difficulty')
->label(__('admin.tasks.fields.difficulty.label'))
->badge(),
Tables\Columns\IconColumn::make('is_active')
->label(__('admin.tasks.table.is_active'))
->boolean(),
Tables\Columns\TextColumn::make('sort_order')
->label(__('admin.tasks.table.sort_order'))
->sortable(),
])
->filters([])
->actions([
@@ -111,4 +167,4 @@ class TaskResource extends Resource
'import' => Pages\ImportTasks::route('/import'),
];
}
}
}

View File

@@ -15,7 +15,7 @@ class ImportTasks extends Page
{
protected static string $resource = TaskResource::class;
protected string $view = 'filament.resources.task-resource.pages.import-tasks';
protected ?string $heading = 'Import Tasks (CSV)';
protected ?string $heading = null;
public ?string $file = null;
@@ -23,7 +23,7 @@ class ImportTasks extends Page
{
return $form->schema([
FileUpload::make('file')
->label('CSV file')
->label(__('admin.common.csv_file'))
->acceptedFileTypes(['text/csv', 'text/plain'])
->directory('imports')
->required(),
@@ -36,7 +36,7 @@ class ImportTasks extends Page
$path = $this->form->getState()['file'] ?? null;
if (!$path || !Storage::disk('public')->exists($path)) {
Notification::make()->danger()->title('File not found')->send();
Notification::make()->danger()->title(__('admin.notifications.file_not_found'))->send();
return;
}
@@ -45,11 +45,16 @@ class ImportTasks extends Page
Notification::make()
->success()
->title("Imported {$ok} rows")
->body($fail ? "{$fail} failed" : null)
->title(__('admin.notifications.imported_rows', ['count' => $ok]))
->body($fail ? __('admin.notifications.failed_count', ['count' => $fail]) : null)
->send();
}
public function getHeading(): string
{
return __('admin.tasks.import.heading');
}
private function importTasksCsv(string $file): array
{
$handle = fopen($file, 'r');

View File

@@ -15,11 +15,11 @@ class ManageTasks extends ManageRecords
return [
Actions\CreateAction::make(),
Actions\Action::make('import')
->label('Import CSV')
->label(__('admin.common.import_csv'))
->icon('heroicon-o-arrow-up-tray')
->url(TaskResource::getUrl('import')),
Actions\Action::make('template')
->label('Download CSV Template')
->label(__('admin.common.download_csv_template'))
->icon('heroicon-o-document-arrow-down')
->url(url('/super-admin/templates/tasks.csv')),
];

View File

@@ -21,34 +21,39 @@ class TenantResource extends Resource
{
protected static ?string $model = Tenant::class;
protected static BackedEnum|string|null $navigationIcon = 'heroicon-o-building-office';
protected static UnitEnum|string|null $navigationGroup = 'Platform';
protected static UnitEnum|string|null $navigationGroup = null;
public static function getNavigationGroup(): UnitEnum|string|null
{
return __('admin.nav.platform');
}
protected static ?int $navigationSort = 10;
public static function form(Schema $form): Schema
{
return $form->schema([
TextInput::make('name')
->label('Tenant Name')
->label(__('admin.tenants.fields.name'))
->required()
->maxLength(255),
TextInput::make('slug')
->label('Slug')
->label(__('admin.tenants.fields.slug'))
->required()
->unique(ignoreRecord: true)
->maxLength(255),
TextInput::make('contact_email')
->label('Contact Email')
->label(__('admin.tenants.fields.contact_email'))
->email()
->required()
->maxLength(255),
TextInput::make('event_credits_balance')
->label('Event Credits Balance')
->label(__('admin.tenants.fields.event_credits_balance'))
->numeric()
->default(0),
KeyValue::make('features')
->label('Features')
->keyLabel('Key')
->valueLabel('Value'),
->label(__('admin.tenants.fields.features'))
->keyLabel(__('admin.common.key'))
->valueLabel(__('admin.common.value')),
])->columns(2);
}
@@ -60,8 +65,8 @@ class TenantResource extends Resource
Tables\Columns\TextColumn::make('name')->searchable()->sortable(),
Tables\Columns\TextColumn::make('slug')->searchable(),
Tables\Columns\TextColumn::make('contact_email'),
Tables\Columns\TextColumn::make('event_credits_balance')->label('Credits'),
Tables\Columns\TextColumn::make('last_activity_at')->since()->label('Last activity'),
Tables\Columns\TextColumn::make('event_credits_balance')->label(__('admin.common.credits')),
Tables\Columns\TextColumn::make('last_activity_at')->since()->label(__('admin.common.last_activity')),
Tables\Columns\TextColumn::make('created_at')->dateTime()->toggleable(isToggledHiddenByDefault: true),
])
->filters([])

View File

@@ -9,7 +9,12 @@ use App\Models\Event;
class EventsActiveToday extends BaseWidget
{
protected static ?string $heading = 'Events active today';
protected static ?string $heading = null;
public function getHeading()
{
return __('admin.widgets.events_active_today.heading');
}
protected ?string $pollingInterval = '60s';
public function table(Tables\Table $table): Tables\Table
@@ -29,11 +34,13 @@ class EventsActiveToday extends BaseWidget
->limit(10)
)
->columns([
Tables\Columns\TextColumn::make('id')->label('#')->width('60px'),
Tables\Columns\TextColumn::make('slug')->label('Slug')->searchable(),
Tables\Columns\TextColumn::make('id')->label(__('admin.common.hash'))->width('60px'),
Tables\Columns\TextColumn::make('slug')->label(__('admin.common.slug'))->searchable(),
Tables\Columns\TextColumn::make('date')->date(),
Tables\Columns\TextColumn::make('uploads_today')->label('Uploads today')->numeric(),
Tables\Columns\TextColumn::make('uploads_today')->label(__('admin.common.uploads_today'))->numeric(),
])
->paginated(false);
}
}

View File

@@ -9,7 +9,12 @@ use Filament\Actions;
class RecentPhotosTable extends BaseWidget
{
protected static ?string $heading = 'Recent uploads';
protected static ?string $heading = null;
public function getHeading()
{
return __('admin.widgets.recent_uploads.heading');
}
protected int|string|array $columnSpan = 'full';
public function table(Tables\Table $table): Tables\Table
@@ -21,22 +26,23 @@ class RecentPhotosTable extends BaseWidget
->limit(10)
)
->columns([
Tables\Columns\ImageColumn::make('thumbnail_path')->label('Thumb')->circular(),
Tables\Columns\TextColumn::make('id')->label('#'),
Tables\Columns\TextColumn::make('event_id')->label('Event'),
Tables\Columns\TextColumn::make('likes_count')->label('Likes'),
Tables\Columns\ImageColumn::make('thumbnail_path')->label(__('admin.common.thumb'))->circular(),
Tables\Columns\TextColumn::make('id')->label(__('admin.common.hash')),
Tables\Columns\TextColumn::make('event_id')->label(__('admin.common.event')),
Tables\Columns\TextColumn::make('likes_count')->label(__('admin.common.likes')),
Tables\Columns\TextColumn::make('created_at')->since(),
])
->actions([
Actions\Action::make('feature')
->label('Feature')
->label(__('admin.photos.actions.feature'))
->visible(fn(Photo $record) => ! (bool)($record->is_featured ?? 0))
->action(fn(Photo $record) => $record->update(['is_featured' => 1])),
Actions\Action::make('unfeature')
->label('Unfeature')
->label(__('admin.photos.actions.unfeature'))
->visible(fn(Photo $record) => (bool)($record->is_featured ?? 0))
->action(fn(Photo $record) => $record->update(['is_featured' => 0])),
])
->paginated(false);
}
}

View File

@@ -8,7 +8,12 @@ use App\Models\Tenant;
class TopTenantsByUploads extends BaseWidget
{
protected static ?string $heading = 'Top tenants by uploads';
protected static ?string $heading = null;
public function getHeading()
{
return __('admin.widgets.top_tenants_by_uploads.heading');
}
protected ?string $pollingInterval = '60s';
public function table(Tables\Table $table): Tables\Table
@@ -21,10 +26,11 @@ class TopTenantsByUploads extends BaseWidget
->limit(5)
)
->columns([
Tables\Columns\TextColumn::make('id')->label('#')->width('60px'),
Tables\Columns\TextColumn::make('name')->label('Tenant')->searchable(),
Tables\Columns\TextColumn::make('photos_count')->label('Uploads')->numeric(),
Tables\Columns\TextColumn::make('id')->label(__('admin.common.hash'))->width('60px'),
Tables\Columns\TextColumn::make('name')->label(__('admin.common.tenant'))->searchable(),
Tables\Columns\TextColumn::make('photos_count')->label(__('admin.common.uploads'))->numeric(),
])
->paginated(false);
}
}

View File

@@ -1,14 +1,13 @@
<?php
namespace App\Filament\Widgets;
use Filament\Widgets\ChartWidget;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Carbon;
class UploadsPerDayChart extends ChartWidget
{
protected ?string $heading = 'Uploads (14 days)';
protected ?string $heading = null;
protected ?string $maxHeight = '220px';
protected ?string $pollingInterval = '60s';
@@ -35,7 +34,7 @@ class UploadsPerDayChart extends ChartWidget
'labels' => $labels,
'datasets' => [
[
'label' => 'Uploads',
'label' => __('admin.common.uploads'),
'data' => $data,
'borderColor' => '#f59e0b',
'backgroundColor' => 'rgba(245, 158, 11, 0.2)',
@@ -49,4 +48,9 @@ class UploadsPerDayChart extends ChartWidget
{
return 'line';
}
}
public function getHeading(): string|\Illuminate\Contracts\Support\Htmlable|null
{
return __('admin.widgets.uploads_per_day.heading');
}
}