Marketing packages now use localized name/description data plus seeded placeholder-
driven breakdown tables, with frontend/cards/dialog updated accordingly (database/ migrations/2025_10_17_000001_add_description_table_to_packages.php, database/ migrations/2025_10_17_000002_add_translation_columns_to_packages.php, database/seeders/PackageSeeder.php, app/ Http/Controllers/MarketingController.php, resources/js/pages/marketing/Packages.tsx). Filament Package resource gains locale tabs, markdown editor, numeric/toggle inputs, and simplified feature management (app/Filament/Resources/PackageResource.php, app/Filament/Resources/PackageResource/Pages/ CreatePackage.php, .../EditPackage.php). Legal pages now render markdown-backed content inside the main layout via a new controller/view route setup and updated footer links (app/Http/Controllers/LegalPageController.php, routes/web.php, resources/views/partials/ footer.blade.php, resources/js/pages/legal/Show.tsx, remove old static pages). Translation files and shared assets updated to cover new marketing/legal strings and styling tweaks (public/ lang/*/marketing.json, resources/lang/*/marketing.php, resources/css/app.css, resources/js/admin/components/ LanguageSwitcher.tsx).
This commit is contained in:
@@ -4,22 +4,26 @@ namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\PackageResource\Pages;
|
||||
use App\Models\Package;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Tabs as SchemaTabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab as SchemaTab;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Columns\BadgeColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
use BackedEnum;
|
||||
|
||||
@@ -35,190 +39,141 @@ class PackageResource extends Resource
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
$featureOptions = static::featureLabelMap();
|
||||
|
||||
return $schema->schema([
|
||||
TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Select::make('type')
|
||||
->label('Type')
|
||||
->options([
|
||||
'endcustomer' => 'Endcustomer',
|
||||
'reseller' => 'Reseller',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('price')
|
||||
->label('Price')
|
||||
->prefix('€')
|
||||
->numeric()
|
||||
->step(0.01)
|
||||
->required()
|
||||
->default(0),
|
||||
TextInput::make('max_photos')
|
||||
->label('Max Photos')
|
||||
->numeric()
|
||||
->nullable(),
|
||||
TextInput::make('max_guests')
|
||||
->label('Max Guests')
|
||||
->numeric()
|
||||
->nullable(),
|
||||
TextInput::make('gallery_days')
|
||||
->label('Gallery Days')
|
||||
->numeric()
|
||||
->nullable(),
|
||||
TextInput::make('max_tasks')
|
||||
->label('Max Tasks')
|
||||
->numeric()
|
||||
->nullable(),
|
||||
Toggle::make('watermark_allowed')
|
||||
->label('Watermark Allowed')
|
||||
->default(true),
|
||||
Toggle::make('branding_allowed')
|
||||
->label('Branding Allowed')
|
||||
->default(false),
|
||||
TextInput::make('max_events_per_year')
|
||||
->label('Max Events per Year')
|
||||
->numeric()
|
||||
->nullable(),
|
||||
Repeater::make('features')
|
||||
->label('Features')
|
||||
->schema([
|
||||
TextInput::make('key')
|
||||
->label('Feature Key'),
|
||||
TextInput::make('value')
|
||||
->label('Feature Value'),
|
||||
])
|
||||
->columns(2)
|
||||
->defaultItems(0),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public static function featuresToRepeaterItems(mixed $features): array
|
||||
{
|
||||
if (is_string($features)) {
|
||||
$decoded = json_decode($features, true);
|
||||
|
||||
if (is_string($decoded)) {
|
||||
$decoded = json_decode($decoded, true);
|
||||
}
|
||||
|
||||
$features = json_last_error() === JSON_ERROR_NONE ? $decoded : null;
|
||||
}
|
||||
|
||||
if ($features === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! is_array($features)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (! array_is_list($features)) {
|
||||
return collect($features)
|
||||
->map(function ($value, $key) {
|
||||
return [
|
||||
'key' => (string) $key,
|
||||
'value' => is_bool($value) ? ($value ? 'true' : 'false') : (string) $value,
|
||||
];
|
||||
})
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
return collect($features)
|
||||
->map(function ($item) {
|
||||
if (is_array($item)) {
|
||||
return [
|
||||
'key' => (string) ($item['key'] ?? ''),
|
||||
'value' => (string) ($item['value'] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'key' => (string) $item,
|
||||
'value' => 'true',
|
||||
];
|
||||
})
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
public static function featuresFromRepeaterItems(mixed $items): array
|
||||
{
|
||||
if (! is_array($items)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$features = [];
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (! is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = isset($item['key']) ? trim((string) $item['key']) : '';
|
||||
|
||||
if ($key === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $item['value'] ?? true;
|
||||
|
||||
if (is_string($value)) {
|
||||
$normalized = strtolower(trim($value));
|
||||
|
||||
if (in_array($normalized, ['1', 'true', 'yes', 'on'], true)) {
|
||||
$value = true;
|
||||
} elseif (in_array($normalized, ['0', 'false', 'no', 'off'], true)) {
|
||||
$value = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$value = $value['value'] ?? $value['enabled'] ?? true;
|
||||
}
|
||||
|
||||
$features[$key] = (bool) $value;
|
||||
}
|
||||
|
||||
return $features;
|
||||
SchemaTabs::make('translations')
|
||||
->columnSpanFull()
|
||||
->tabs([
|
||||
SchemaTab::make('Deutsch')
|
||||
->schema([
|
||||
TextInput::make('name_translations.de')
|
||||
->label('Name (DE)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
MarkdownEditor::make('description_translations.de')
|
||||
->label('Beschreibung (DE)')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
SchemaTab::make('English')
|
||||
->schema([
|
||||
TextInput::make('name_translations.en')
|
||||
->label('Name (EN)')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
MarkdownEditor::make('description_translations.en')
|
||||
->label('Description (EN)')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
]),
|
||||
Section::make('Allgemeine Einstellungen')
|
||||
->columns(3)
|
||||
->schema([
|
||||
TextInput::make('slug')
|
||||
->label('Slug')
|
||||
->required()
|
||||
->maxLength(191)
|
||||
->unique(ignoreRecord: true),
|
||||
Select::make('type')
|
||||
->label('Paket-Typ')
|
||||
->options([
|
||||
'endcustomer' => 'Endkunde',
|
||||
'reseller' => 'Reseller',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('price')
|
||||
->label('Preis')
|
||||
->numeric()
|
||||
->step(0.01)
|
||||
->prefix('€')
|
||||
->required(),
|
||||
TextInput::make('max_photos')
|
||||
->label('Max. Fotos')
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->nullable(),
|
||||
TextInput::make('max_guests')
|
||||
->label('Max. Gäste')
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->nullable(),
|
||||
TextInput::make('gallery_days')
|
||||
->label('Galeriedauer (Tage)')
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->nullable(),
|
||||
TextInput::make('max_tasks')
|
||||
->label('Max. Fotoaufgaben')
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->nullable(),
|
||||
TextInput::make('max_events_per_year')
|
||||
->label('Events pro Jahr')
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->nullable()
|
||||
->visible(fn ($get) => $get('type') === 'reseller'),
|
||||
Toggle::make('watermark_allowed')
|
||||
->label('Wasserzeichen erlaubt')
|
||||
->default(true),
|
||||
Toggle::make('branding_allowed')
|
||||
->label('Eigenes Branding erlaubt')
|
||||
->default(false),
|
||||
]),
|
||||
Section::make('Features & Kennzahlen')
|
||||
->columns(1)
|
||||
->schema([
|
||||
CheckboxList::make('features')
|
||||
->label('Aktive Features')
|
||||
->options($featureOptions)
|
||||
->columns(2)
|
||||
->default([]),
|
||||
Repeater::make('description_table')
|
||||
->label('Kenndaten')
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
->label('Titel')
|
||||
->maxLength(255),
|
||||
TextInput::make('value')
|
||||
->label('Wert / Beschreibung')
|
||||
->maxLength(255),
|
||||
])
|
||||
->addActionLabel('Eintrag hinzufügen')
|
||||
->reorderable()
|
||||
->columnSpanFull()
|
||||
->default([]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function formatFeaturesForDisplay(mixed $features): string
|
||||
{
|
||||
$map = $features;
|
||||
|
||||
if (! is_array($map)) {
|
||||
if (is_string($map)) {
|
||||
$decoded = json_decode($map, true);
|
||||
|
||||
if (is_string($decoded)) {
|
||||
$decoded = json_decode($decoded, true);
|
||||
}
|
||||
|
||||
$map = json_last_error() === JSON_ERROR_NONE ? $decoded : [];
|
||||
} else {
|
||||
$map = [];
|
||||
if (is_string($features)) {
|
||||
$decoded = json_decode($features, true);
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
$features = $decoded;
|
||||
}
|
||||
}
|
||||
|
||||
if (! array_is_list($map)) {
|
||||
return collect($map)
|
||||
->filter(fn ($value) => (bool) $value)
|
||||
->keys()
|
||||
if (! is_array($features)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$labels = static::featureLabelMap();
|
||||
|
||||
if (array_is_list($features)) {
|
||||
return collect($features)
|
||||
->filter(fn ($value) => is_string($value) && $value !== '')
|
||||
->map(fn ($value) => $labels[$value] ?? $value)
|
||||
->implode(', ');
|
||||
}
|
||||
|
||||
return collect($map)
|
||||
->map(function ($item) {
|
||||
if (is_array($item)) {
|
||||
return (string) ($item['key'] ?? '');
|
||||
}
|
||||
|
||||
return (string) $item;
|
||||
})
|
||||
->filter()
|
||||
return collect($features)
|
||||
->filter(fn ($value) => (bool) $value)
|
||||
->keys()
|
||||
->map(fn ($value) => $labels[$value] ?? $value)
|
||||
->implode(', ');
|
||||
}
|
||||
|
||||
@@ -226,35 +181,45 @@ class PackageResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Name')
|
||||
TextColumn::make('name_translations.de')
|
||||
->label('Name (DE)')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('type')
|
||||
->label('Type')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'endcustomer' => 'info',
|
||||
'reseller' => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextColumn::make('name_translations.en')
|
||||
->label('Name (EN)')
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
BadgeColumn::make('type')
|
||||
->label('Typ')
|
||||
->colors([
|
||||
'info' => 'endcustomer',
|
||||
'warning' => 'reseller',
|
||||
]),
|
||||
TextColumn::make('price')
|
||||
->label('Price')
|
||||
->label('Preis')
|
||||
->money('EUR')
|
||||
->sortable(),
|
||||
IconColumn::make('max_photos')
|
||||
->label('Max Photos')
|
||||
->icon('heroicon-o-photo')
|
||||
->color('primary'),
|
||||
TextColumn::make('max_photos')
|
||||
->label('Fotos')
|
||||
->sortable(),
|
||||
TextColumn::make('max_guests')
|
||||
->label('Gäste')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('features')
|
||||
->label('Features')
|
||||
->formatStateUsing(fn ($state) => static::formatFeaturesForDisplay($state))
|
||||
->limit(50),
|
||||
->wrap()
|
||||
->formatStateUsing(fn ($state) => static::formatFeaturesForDisplay($state)),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
Tables\Filters\SelectFilter::make('type')
|
||||
->label('Typ')
|
||||
->options([
|
||||
'endcustomer' => 'Endkunde',
|
||||
'reseller' => 'Reseller',
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
@@ -265,13 +230,6 @@ class PackageResource extends Resource
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
@@ -280,4 +238,19 @@ class PackageResource extends Resource
|
||||
'edit' => Pages\EditPackage::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
protected static function featureLabelMap(): array
|
||||
{
|
||||
return [
|
||||
'basic_uploads' => 'Basis-Uploads',
|
||||
'unlimited_sharing' => 'Unbegrenztes Teilen',
|
||||
'no_watermark' => 'Kein Wasserzeichen',
|
||||
'custom_branding' => 'Eigenes Branding',
|
||||
'custom_tasks' => 'Eigene Aufgaben',
|
||||
'advanced_analytics' => 'Erweiterte Analytics',
|
||||
'advanced_reporting' => 'Erweiterte Reports',
|
||||
'live_slideshow' => 'Live-Slideshow',
|
||||
'priority_support' => 'Priorisierter Support',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user