Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
101 lines
3.6 KiB
PHP
101 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Support\Branding;
|
|
use App\Support\Settings;
|
|
use BackedEnum;
|
|
use Filament\Forms\Components\ColorPicker;
|
|
use Filament\Forms\Components\FileUpload;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Pages\Page;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use UnitEnum;
|
|
|
|
/**
|
|
* Basis-Branding (Phase 0). Die vollständige Seite „Erscheinungsbild“ mit
|
|
* Logo-Varianten, Schriften, Vorschau usw. folgt in Phase 5.
|
|
*/
|
|
class Appearance extends Page
|
|
{
|
|
protected string $view = 'filament.pages.appearance';
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPaintBrush;
|
|
|
|
protected static string|UnitEnum|null $navigationGroup = 'System';
|
|
|
|
protected static ?string $navigationLabel = 'Erscheinungsbild';
|
|
|
|
protected static ?string $title = 'Erscheinungsbild';
|
|
|
|
protected static ?string $slug = 'erscheinungsbild';
|
|
|
|
/** @var array<string, mixed>|null */
|
|
public ?array $data = [];
|
|
|
|
public function mount(Branding $branding): void
|
|
{
|
|
$this->form->fill([
|
|
'portal_name' => $branding->portalName(),
|
|
'primary_color' => $branding->primaryColor(),
|
|
'logo_path' => $branding->logoPath(),
|
|
]);
|
|
}
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make('Portal')
|
|
->description('Name und Logo erscheinen im Kopfbereich, auf der Anmeldeseite und im Browser-Tab.')
|
|
->schema([
|
|
TextInput::make('portal_name')
|
|
->label('Name des Portals')
|
|
->placeholder(Branding::DEFAULT_NAME)
|
|
->maxLength(60),
|
|
FileUpload::make('logo_path')
|
|
->label('Logo')
|
|
->helperText('SVG, PNG oder WebP, am besten mit transparentem Hintergrund.')
|
|
->disk('uploads')
|
|
->directory('branding')
|
|
->visibility('public')
|
|
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp'])
|
|
->maxSize(2048),
|
|
]),
|
|
Section::make('Farben')
|
|
->description('Aus der Primärfarbe wird die komplette Farbpalette für den hellen und den dunklen Modus berechnet.')
|
|
->schema([
|
|
ColorPicker::make('primary_color')
|
|
->label('Primärfarbe')
|
|
->regex('/^#[0-9a-fA-F]{6}$/')
|
|
->required(),
|
|
]),
|
|
])
|
|
->statePath('data');
|
|
}
|
|
|
|
public function save(Settings $settings, Branding $branding): void
|
|
{
|
|
$data = $this->form->getState();
|
|
$previousLogo = $branding->logoPath();
|
|
|
|
$settings->setMany([
|
|
'branding.portal_name' => filled($data['portal_name']) ? trim($data['portal_name']) : null,
|
|
'branding.primary_color' => strtoupper($data['primary_color']),
|
|
'branding.logo_path' => $data['logo_path'] ?: null,
|
|
]);
|
|
|
|
if ($previousLogo && $previousLogo !== $data['logo_path']) {
|
|
Storage::disk('uploads')->delete($previousLogo);
|
|
}
|
|
|
|
Notification::make()
|
|
->success()
|
|
->title('Erscheinungsbild gespeichert')
|
|
->send();
|
|
}
|
|
}
|