first(); if ($settings) { $this->asset = $settings->asset ? [$settings->asset] : []; $this->position = $settings->position; $this->opacity = (float) $settings->opacity; $this->scale = (float) $settings->scale; $this->padding = (int) $settings->padding; $this->offset_x = (int) ($settings->offset_x ?? 0); $this->offset_y = (int) ($settings->offset_y ?? 0); } } public function form(Schema $schema): Schema { return $schema->schema([ Forms\Components\FileUpload::make('asset') ->label('Basis-Wasserzeichen (PNG/SVG empfohlen)') ->disk('public') ->directory('branding') ->preserveFilenames() ->image() ->required(), Forms\Components\Select::make('position') ->label('Position') ->options([ 'top-left' => 'Oben links', 'top-right' => 'Oben rechts', 'bottom-left' => 'Unten links', 'bottom-right' => 'Unten rechts', 'center' => 'Zentriert', ]) ->required(), Forms\Components\TextInput::make('opacity') ->label('Opacity (0–1)') ->numeric() ->minValue(0) ->maxValue(1) ->step(0.05) ->default(0.25) ->required(), Forms\Components\TextInput::make('scale') ->label('Skalierung (0–1, relativ zur Bildbreite)') ->numeric() ->minValue(0.05) ->maxValue(1) ->step(0.05) ->default(0.2) ->required(), Forms\Components\TextInput::make('padding') ->label('Padding (px)') ->numeric() ->minValue(0) ->default(16) ->required(), Forms\Components\TextInput::make('offset_x') ->label('Offset X (px)') ->numeric() ->minValue(-500) ->maxValue(500) ->default(0) ->required(), Forms\Components\TextInput::make('offset_y') ->label('Offset Y (px)') ->numeric() ->minValue(-500) ->maxValue(500) ->default(0) ->required(), ])->columns(2); } public function save(): void { $this->validate(); $state = $this->form->getState(); $asset = $state['asset'] ?? $this->asset; if (is_array($asset)) { $asset = $asset[0] ?? null; } $settings = WatermarkSetting::query()->firstOrNew([]); $settings->asset = $asset; $settings->position = $this->position; $settings->opacity = $this->opacity; $settings->scale = $this->scale; $settings->padding = $this->padding; $settings->offset_x = $this->offset_x; $settings->offset_y = $this->offset_y; $settings->save(); $changed = $settings->getChanges(); if ($changed !== []) { app(SuperAdminAuditLogger::class)->record( 'watermark_settings.updated', $settings, SuperAdminAuditLogger::fieldsMetadata(array_keys($changed)), source: static::class ); } Notification::make() ->title('Wasserzeichen aktualisiert') ->success() ->send(); } }