getRecord()->name; } public function getHeading(): string|Htmlable { return ''; } /** * @return array */ public function getBreadcrumbs(): array { return []; } public function getMaxContentWidth(): Width|string|null { return Width::Full; } public function infolist(Schema $schema): Schema { return $schema->components([ View::make('filament.catalog.objekt')->viewData(fn (): array => $this->profilDaten())->columnSpanFull(), ])->columns(1); } /** * @return array */ private function profilDaten(): array { /** @var RightsProfile $profile */ $profile = $this->getRecord(); $versions = $profile->versions()->orderByDesc('number')->get(); $current = $versions->first(); $faehigkeiten = CatalogLabels::faehigkeiten($current?->capabilities); $optionen = collect($current?->options ?? [])->map(fn (mixed $wert, string $schluessel): array => [ 'text' => $schluessel, 'neben' => is_scalar($wert) ? (string) $wert : json_encode($wert, JSON_UNESCAPED_UNICODE), ])->values()->all(); $verwendung = OfferLine::query() ->whereIn('rights_profile_version_id', $versions->pluck('id')) ->with(['offerVersion.offer', 'article', 'bundleVersion.bundle']) ->get() ->map(fn (OfferLine $line): array => [ 'text' => ($line->offerVersion?->offer?->name ?? 'Angebot').' · Fassung '.($line->offerVersion?->number ?? '–'), 'zustand' => StatusValue::of($line->offerVersion?->status) === OfferStatus::Aktiv->value ? ['label' => 'Aktiv', 'ton' => 'gut'] : ['label' => StatusValue::of($line->offerVersion?->status) === OfferStatus::Beendet->value ? 'Beendet' : 'Entwurf', 'ton' => 'leise'], 'neben' => $line->article !== null ? 'Lizenzartikel '.$line->article->code : 'Paket '.($line->bundleVersion?->bundle?->name ?? '–'), ])->all(); return [ 'kopf' => [ 'brot' => [['label' => 'Rechteprofile', 'href' => RightsProfileResource::getUrl('index')], $profile->name], 'titel' => $profile->name, 'typ' => 'Rechteprofil', 'status' => $current === null ? ['text' => 'Noch keine Fassung', 'ton' => 'offen'] : ['text' => 'Fassung '.$current->number.' · '.CatalogLabels::zweck($current->purpose).($current->locked_at !== null ? ' · festgeschrieben seit '.$current->locked_at->format('d.m.Y') : ''), 'ton' => 'neutral'], ], 'haupt' => [ [ 'titel' => 'Erlaubte Handlungen', 'zusatz' => $current !== null ? 'Fassung '.$current->number : null, 'hilfe' => $current?->locked_at !== null ? 'Diese Fassung wird in einem aktiven Angebot verwendet und ist deshalb unveränderlich.' : 'Zweck und erlaubte Handlungen. Angebote verbinden das Profil mit Lizenzartikeln.', 'zeilen' => array_map(fn (string $label): array => ['text' => $label], $faehigkeiten), 'leer' => ['titel' => 'Keine Handlungen', 'text' => 'Diese Fassung erlaubt keine Handlung.'], ], ...($optionen !== [] ? [['titel' => 'Optionen', 'zeilen' => $optionen]] : []), ], 'seite' => [ [ 'titel' => 'In Angeboten', 'zeilen' => $verwendung, 'leer' => 'In keinem Angebot verwendet.', ], [ 'titel' => 'Fassungen', 'zeilen' => $versions->map(fn (RightsProfileVersion $version): array => [ 'text' => 'Fassung '.$version->number, 'zustand' => $version->locked_at !== null ? ['label' => 'Festgeschrieben', 'ton' => 'leise'] : null, 'neben' => CatalogLabels::zweck($version->purpose), ])->all(), ], ], ]; } }