CI Feature / test (push) Failing after 20s
- Seite → Abschnitte → Plätze → Widgets: sechs Raster mit höchstens vier Einheiten, Hintergrund, Breite, Abstand und Trenner als Aufzählungswerte; je Platz ein Widget aus dem bestehenden Register. Neue Spalte page_revisions.sections (ergänzend); blocks erhält weiterhin alle Widgets in Lesereihenfolge als Rollback-Fassung. - Widgets erhalten Mindest- und Vorzugsbreite; Darstellung über Container-Abfragen. - Editor: Abschnitts-Repeater mit grafischer Rasterauswahl, Plätzen im Rasterverhältnis, breiter Arbeitsfläche, kompakten Vorschauen ohne Bildlaufleiste, Meldungen mit Abschnitt und Platz; Rasterwechsel entfernt nie ein Widget. Seite duplizieren. - Designsystem: Marken- und Bedeutungs-Tokens (vorläufig), gemeinsame Grundkomponenten, Nunito/Source Sans 3 lokal; Mitgliederbereich nutzt dieselben Tokens und die Wortmarke. - Kopfzeile, mobile Navigation, Untermenü (parent_id, ergänzend), Fußbereichsgruppen, vorbereiteter Warenkorbzugang (abgeschaltet). Öffentliche Seiten gleich für alle Besucher. - cms:revert-published als Wiederherstellungsweg vor einem Code-Rollback. Die Editor-Tests der ersten Iteration sind bewusst auf den neuen Formularzustand (sections statt blocks) umgestellt; ihre Prüfungen gelten unverändert für die Widgets. Der Vorschautest erwartet keine anmeldeabhängige Kopfzeile mehr (ADR-32). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
115 lines
2.9 KiB
PHP
115 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Cms;
|
|
|
|
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class NavigationItem extends Model
|
|
{
|
|
/**
|
|
* Plätze im globalen Website-Gerüst. Die drei Fußbereichsgruppen ersetzen eine eigene Footer-Verwaltung.
|
|
*/
|
|
public const PLACEMENTS = [
|
|
'header' => 'Kopfzeile (Hauptnavigation)',
|
|
'footer' => 'Fußbereich: Service',
|
|
'footer_contact' => 'Fußbereich: Kontakt',
|
|
'footer_legal' => 'Fußbereich: Rechtliches',
|
|
];
|
|
|
|
/** Spaltenüberschriften im Fußbereich. */
|
|
public const FOOTER_GROUPS = [
|
|
'footer' => 'Service',
|
|
'footer_contact' => 'Kontakt',
|
|
'footer_legal' => 'Rechtliches',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'label',
|
|
'page_id',
|
|
'url',
|
|
'placement',
|
|
'sort_order',
|
|
'is_visible',
|
|
'parent_id',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{
|
|
// Untermenüs gibt es nur in der Hauptnavigation.
|
|
static::saving(function (NavigationItem $item): void {
|
|
if ($item->placement !== 'header' && $item->getAttribute('parent_id') !== null) {
|
|
$item->parent_id = null;
|
|
}
|
|
});
|
|
}
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_visible' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function page(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Page::class);
|
|
}
|
|
|
|
public function parent(): BelongsTo
|
|
{
|
|
return $this->belongsTo(self::class, 'parent_id');
|
|
}
|
|
|
|
public function children(): HasMany
|
|
{
|
|
return $this->hasMany(self::class, 'parent_id')->orderBy('sort_order')->orderBy('id');
|
|
}
|
|
|
|
/**
|
|
* @param Builder<NavigationItem> $query
|
|
*/
|
|
public function scopeVisible(Builder $query): void
|
|
{
|
|
$query->where('is_visible', true);
|
|
}
|
|
|
|
public function href(): ?string
|
|
{
|
|
if ($this->page !== null) {
|
|
return $this->page->path === '/' ? url('/') : url($this->page->path);
|
|
}
|
|
|
|
if ($this->url === null || $this->url === '' || ! SafeUrl::isSafe($this->url)) {
|
|
return null;
|
|
}
|
|
|
|
if (str_starts_with($this->url, '/')) {
|
|
return url($this->url);
|
|
}
|
|
|
|
return $this->url;
|
|
}
|
|
|
|
/**
|
|
* Pfad des Ziels innerhalb der Website (für die Kennzeichnung des aktiven Eintrags); null bei externen Zielen.
|
|
*/
|
|
public function targetPath(): ?string
|
|
{
|
|
if ($this->page !== null) {
|
|
return $this->page->path;
|
|
}
|
|
|
|
if (is_string($this->url) && str_starts_with($this->url, '/') && ! str_starts_with($this->url, '//')) {
|
|
$path = parse_url($this->url, PHP_URL_PATH);
|
|
|
|
return is_string($path) ? '/'.trim($path, '/') : null;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|