*/ use HasFactory; public const HOME = 'start'; /** Menu locations a page can appear in. */ public const MENU_LOCATIONS = ['main' => 'Hauptmenü', 'footer' => 'Fußzeile', 'none' => 'Nicht im Menü']; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'is_published' => 'boolean', 'sections' => 'array', ]; } /** * @return BelongsTo */ public function site(): BelongsTo { return $this->belongsTo(Site::class); } public function isHome(): bool { return $this->slug === self::HOME; } public function url(): string { return $this->isHome() ? route('home') : route('page', ['slug' => $this->slug]); } public function label(): string { return $this->menu_label ?: $this->title; } }