Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32837639e6 | ||
|
|
3825f53a9b | ||
|
|
604e1791c5 | ||
|
|
cd66561ca9 | ||
|
|
886715af96 | ||
|
|
05bd36509c | ||
|
|
96bb661239 | ||
|
|
340b898b7b | ||
|
|
9701777011 | ||
|
|
4520dba2f0 | ||
|
|
d49b178ebd | ||
|
|
da7ebca999 | ||
|
|
f72b79fd8c | ||
|
|
4e0760db1e | ||
|
|
6c8bbee363 | ||
|
|
7ad5929588 | ||
|
|
ed1f706d46 | ||
|
|
7c48a6480c | ||
|
|
d5c2b34b9d | ||
|
|
eb6192b067 |
No files matched your search
@@ -63,6 +63,6 @@ ## Entwicklung
|
||||
## Verwaltungsoberfläche
|
||||
|
||||
- Maßgeblich sind `docs/ux/verwaltung/14-verwaltungsstandard.md` (Design und Interaktion) und `15-umbauauftrag.md` (Auftrag, Nachweise). Keine neue allgemeine Designabstimmung verlangen. Einstieg für alle Agenten: `AGENTS.md`, `.cursor/rules/verwaltung-ux.mdc`.
|
||||
- Gemeinsame Bausteine wiederverwenden statt neue Masken bauen: `resources/views/filament/verwaltung/` (`kopf`, `redaktion`, `texte`, `praesentation`, `einordnung`, `picker`, `bestaetigung`, `abgang`, `aufbau`, `bestand`) mit dem Trait `App\Filament\Support\ManagesEditorialSurface`. Listen nutzen `verwaltung/bestand` mit `ShowsBestand` (bzw. `ListsCompositions`, `ListsCatalog`) und den Eintrag `<x-vw.eintrag>`, den auch der Picker verwendet; Katalogobjekte die Seite `catalog/objekt`. CMS: Seitenkopf `cms/seite-kopf` (Register, Kontexte „Abschnitt gestalten“ und „Konfigurieren“); Seiten und Menüs in der Webpräsenz (`App\Filament\Pages\Webpraesenz`, Menüs als Arbeitsstand mit einer Speicherhandlung). Der Picker liegt im Trait `ChoosesMedia` (Redaktion über `ManagesEditorialSurface`, CMS-Bilder über `ChoosesWebsiteImages`); keine eigenen Auswahllisten für Medien bauen. Redaktionelle Auswahlwerte (Materialart, Einordnung) nur über `App\Domain\Catalog\EditorialVocabulary` anbieten und prüfen (aktiv, zulässiger Kontext, vorhandene Zuordnungen erhalten); gepflegt werden sie unter „Redaktionelle Stammdaten“. Ersetzt eine Seite die Filament-Tabelle, muss sie den Dialogbereich ausgeben (in `bestand` enthalten), sonst öffnen „… anlegen“-Dialoge nicht. Gestaltungswerte nur in `verwaltung/styles.blade.php` (Tokens `--vw-…`, dokumentiert in `docs/ux/verwaltung/tokens.md`).
|
||||
- Gemeinsame Bausteine wiederverwenden statt neue Masken bauen: `resources/views/filament/verwaltung/` (`kopf`, `redaktion`, `texte`, `praesentation`, `einordnung`, `picker`, `bestaetigung`, `abgang`, `aufbau`, `bestand`) mit dem Trait `App\Filament\Support\ManagesEditorialSurface`. Listen nutzen `verwaltung/bestand` mit `ShowsBestand` (bzw. `ListsCompositions`, `ListsCatalog`) und den Eintrag `<x-vw.eintrag>`, den auch der Picker verwendet; Katalogobjekte die Seite `catalog/objekt`. CMS: Seitenkopf `cms/seite-kopf` (Register, Kontexte „Abschnitt gestalten“ und „Konfigurieren“); Seiten und Menüs in der Webpräsenz (`App\Filament\Pages\Webpraesenz`, Menüs als Arbeitsstand mit einer Speicherhandlung). Der Picker liegt im Trait `ChoosesMedia` (Redaktion über `ManagesEditorialSurface`, CMS-Bilder über `ChoosesWebsiteImages`); keine eigenen Auswahllisten für Medien bauen. Redaktionelle Auswahlwerte (Materialart, Einordnung) nur über `App\Domain\Catalog\EditorialVocabulary` anbieten und prüfen (aktiv, zulässiger Kontext, vorhandene Zuordnungen erhalten); gepflegt werden sie unter „Redaktionelle Stammdaten“. Fachliche Säulen gibt es nur in der Säulenverwaltung (`pillars`); Zuordnung über `PillarService::assign`, nie über eine Dimension. Ersetzt eine Seite die Filament-Tabelle, muss sie den Dialogbereich ausgeben (in `bestand` enthalten), sonst öffnen „… anlegen“-Dialoge nicht. Gestaltungswerte nur in `verwaltung/styles.blade.php` (Tokens `--vw-…`, dokumentiert in `docs/ux/verwaltung/tokens.md`).
|
||||
- Die Redaktion ist ein Arbeitsstand: nur „Redaktion speichern“ schreibt Texte, Einordnung, Präsentationsmedien und Abweichungen. Kein verdecktes Mitspeichern aus anderen Dialogen, offene Eingaben bleiben beim Wechsel erhalten.
|
||||
- Jede UI-Änderung in der echten Anwendung prüfen (luf-test, breite und schmale Fenster, Tastatur) und mit Screenshots in `docs/ux/verwaltung/abnahme/` belegen. Stand der Abnahme: `abnahme/teil-a.md`, `abnahme/teil-b.md`, `abnahme/teil-c.md`, `abnahme/stammdaten.md`.
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Domain\Catalog\LegacyPillarAdoption;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class AdoptLegacyPillars extends Command
|
||||
{
|
||||
protected $signature = 'luf:saeulen-uebernehmen {--dry-run : Nur berichten, nichts schreiben}';
|
||||
|
||||
protected $description = 'Übernimmt die alte Dimension „Fachliche Säule“ in die zentrale Säulenverwaltung und berichtet ungeklärte Fälle';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$dryRun = (bool) $this->option('dry-run');
|
||||
$report = (new LegacyPillarAdoption)->run($dryRun);
|
||||
|
||||
foreach (LegacyPillarAdoption::lines($report, $dryRun) as $line) {
|
||||
$this->line($line);
|
||||
}
|
||||
|
||||
return $report['unresolved'] === [] ? self::SUCCESS : self::FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Composition extends Model
|
||||
@@ -44,4 +45,13 @@ public function versions(): HasMany
|
||||
{
|
||||
return $this->hasMany(CompositionVersion::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkt zugeordnete fachliche Säulen (zentrale Säulenverwaltung). Die Säulen der enthaltenen Medien sind davon
|
||||
* getrennt und werden zur Laufzeit abgeleitet (CatalogReading::memberPillars).
|
||||
*/
|
||||
public function pillars(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Pillar::class)->orderBy('pillars.sort_order')->orderBy('pillars.name');
|
||||
}
|
||||
}
|
||||
@@ -20,20 +20,15 @@ public function values(): HasMany
|
||||
}
|
||||
|
||||
/**
|
||||
* Inhaltselemente pflegen Themen über die Säulen, nicht noch einmal über die Dimension.
|
||||
* Module, Programme und Lizenzartikel haben keine Säulenauswahl und behalten die Dimension.
|
||||
* Fachliche Säulen werden für alle Objektarten über die zentrale Säulenverwaltung gewählt (`pillars`), nie über
|
||||
* eine Dimension. Die alte Dimension „Fachliche Säule“ bleibt nur als Verlauf in der Datenbank und wird nirgends
|
||||
* mehr angeboten, geändert oder gefiltert.
|
||||
*
|
||||
* @return Collection<int, self>
|
||||
*/
|
||||
public static function forSubject(Model $subject): Collection
|
||||
{
|
||||
$query = static::query()->with('values')->orderBy('label');
|
||||
|
||||
if ($subject instanceof ContentElement) {
|
||||
$query->where('slug', '!=', self::PILLAR_SLUG);
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
return static::query()->with('values')->where('slug', '!=', self::PILLAR_SLUG)->orderBy('label')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
class EditorialDimensionValue extends Model
|
||||
{
|
||||
protected $fillable = ['editorial_dimension_id', 'slug', 'label', 'sort_order', 'is_active'];
|
||||
protected $fillable = ['editorial_dimension_id', 'pillar_id', 'slug', 'label', 'sort_order', 'is_active'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
|
||||
@@ -181,13 +181,13 @@ public function dimensionGroups(Model $subject, array $assignedIds): array
|
||||
* @param list<int> $selectedIds
|
||||
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
|
||||
*/
|
||||
public function dimensionFilterGroups(array $selectedIds = [], bool $withPillars = true): array
|
||||
public function dimensionFilterGroups(array $selectedIds = []): array
|
||||
{
|
||||
$used = DB::table('identity_dimension_values')->distinct()->pluck('editorial_dimension_value_id')->map(fn ($id): int => (int) $id)->all();
|
||||
$groups = [];
|
||||
|
||||
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
|
||||
if (! $withPillars && $dimension->slug === EditorialDimension::PILLAR_SLUG) {
|
||||
if ($dimension->slug === EditorialDimension::PILLAR_SLUG) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public function dimensionFilterGroups(array $selectedIds = [], bool $withPillars
|
||||
*/
|
||||
public function memberFilterDimensions(array $selectedIds = []): Collection
|
||||
{
|
||||
$dimensions = EditorialDimension::query()->with('values')->orderBy('label')->get();
|
||||
$dimensions = EditorialDimension::query()->with('values')->where('slug', '!=', EditorialDimension::PILLAR_SLUG)->orderBy('label')->get();
|
||||
|
||||
foreach ($dimensions as $dimension) {
|
||||
$dimension->setRelation('values', $dimension->values
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Übernimmt die frühere Kopie „Fachliche Säule“ (Dimension `saeule`) in die zentrale Säulenverwaltung (Tabelle
|
||||
* `pillars`). Verlustfrei, wiederholbar und ohne Raten:
|
||||
*
|
||||
* - **Zuordnung Wert → Säule** nur über die gespeicherte Kennung `pfeiler-{Säulenkennung}`, die die Migration
|
||||
* vom 16.11.2026 beim Spiegeln geschrieben hat, und nur, wenn die Säule existiert und nicht jünger als der Wert ist
|
||||
* (sonst kann die Kennung nicht aus ihr entstanden sein). Eine abweichende Bezeichnung ist nach einem Umbenennen
|
||||
* erwartet und wird nur berichtet. Die Verknüpfung steht in `editorial_dimension_values.pillar_id`.
|
||||
* - **Übernommen** werden nur direkte Zuordnungen von Modulen, Programmen und Lizenzartikeln in `composition_pillar`
|
||||
* und `license_article_pillar` (insert-or-ignore, daher beliebig oft ausführbar).
|
||||
* - **Nicht übernommen, sondern gemeldet:** Werte ohne belastbare Kennung, Zuordnungen zu fehlenden Objekten,
|
||||
* abgeleitete Zuordnungen und unbekannte Objektarten. Abgeleitete Säulen eines Programms oder Moduls entstehen zur
|
||||
* Laufzeit aus den enthaltenen Medien und werden nie als direkte Zuordnung gespeichert.
|
||||
* - **Medien:** Die gespiegelten Zeilen sind eine veraltete Kopie; maßgeblich ist `content_element_pillar`. Sie werden
|
||||
* nicht zurückgemischt, nur gezählt.
|
||||
* - Alte Zeilen werden weder geändert noch gelöscht.
|
||||
*
|
||||
* Nur die Datenbankfassade, damit spätere Änderungen an Modellen die Migration nicht berühren.
|
||||
*/
|
||||
final class LegacyPillarAdoption
|
||||
{
|
||||
/** @var array<string, array{table: string, column: string, subjects: string}> */
|
||||
private const TARGETS = [
|
||||
'composition' => ['table' => 'composition_pillar', 'column' => 'composition_id', 'subjects' => 'compositions'],
|
||||
'license_article' => ['table' => 'license_article_pillar', 'column' => 'license_article_id', 'subjects' => 'license_articles'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* mapping: list<array<string, mixed>>,
|
||||
* unresolved: list<array<string, mixed>>,
|
||||
* copied: array<string, int>,
|
||||
* already: array<string, int>,
|
||||
* before: array<string, int>,
|
||||
* after: array<string, int>,
|
||||
* mirror: array<string, int>
|
||||
* }
|
||||
*/
|
||||
public function run(bool $dryRun = false): array
|
||||
{
|
||||
$report = [
|
||||
'mapping' => [],
|
||||
'unresolved' => [],
|
||||
'copied' => ['composition' => 0, 'license_article' => 0],
|
||||
'already' => ['composition' => 0, 'license_article' => 0],
|
||||
'before' => $this->counts(),
|
||||
'after' => [],
|
||||
'mirror' => ['element_rows' => 0, 'missing_in_pivot' => 0, 'only_in_pivot' => 0],
|
||||
];
|
||||
|
||||
$dimension = DB::table('editorial_dimensions')->where('slug', 'saeule')->first();
|
||||
|
||||
if ($dimension === null) {
|
||||
$report['after'] = $report['before'];
|
||||
|
||||
return $report;
|
||||
}
|
||||
|
||||
$resolved = [];
|
||||
|
||||
foreach (DB::table('editorial_dimension_values')->where('editorial_dimension_id', $dimension->id)->orderBy('id')->get() as $value) {
|
||||
$pillar = $this->pillarFor($value);
|
||||
|
||||
if (is_string($pillar)) {
|
||||
$report['unresolved'][] = ['art' => 'Wert', 'wert_id' => (int) $value->id, 'wert' => $value->label, 'kennung' => $value->slug, 'grund' => $pillar];
|
||||
$report['mapping'][] = ['wert_id' => (int) $value->id, 'wert' => $value->label, 'saeule_id' => null, 'status' => 'offen'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$resolved[(int) $value->id] = (int) $pillar->id;
|
||||
$status = $value->pillar_id === null ? 'zugeordnet' : 'bereits zugeordnet';
|
||||
$hint = $value->label !== $pillar->name ? 'über Kennung zugeordnet, Bezeichnung weicht ab („'.$pillar->name.'“)' : null;
|
||||
$report['mapping'][] = ['wert_id' => (int) $value->id, 'wert' => $value->label, 'saeule_id' => (int) $pillar->id, 'saeule' => $pillar->name, 'status' => $status, 'hinweis' => $hint];
|
||||
|
||||
if ($value->pillar_id === null && ! $dryRun) {
|
||||
DB::table('editorial_dimension_values')->where('id', $value->id)->update(['pillar_id' => $pillar->id]);
|
||||
}
|
||||
}
|
||||
|
||||
$subjectTypes = $this->subjectTypes();
|
||||
|
||||
foreach (DB::table('identity_dimension_values')
|
||||
->whereIn('editorial_dimension_value_id', DB::table('editorial_dimension_values')->where('editorial_dimension_id', $dimension->id)->select('id'))
|
||||
->orderBy('id')->get() as $row) {
|
||||
$valueId = (int) $row->editorial_dimension_value_id;
|
||||
$label = DB::table('editorial_dimension_values')->where('id', $valueId)->value('label');
|
||||
$target = $subjectTypes[$row->subject_type] ?? null;
|
||||
|
||||
if ($target === 'content_element') {
|
||||
$report['mirror']['element_rows']++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$where = ['art' => 'Zuordnung', 'zuordnung_id' => (int) $row->id, 'wert_id' => $valueId, 'wert' => $label, 'objektart' => $row->subject_type, 'objekt_id' => (int) $row->subject_id, 'herkunft' => $row->origin];
|
||||
|
||||
if ($target === null) {
|
||||
$report['unresolved'][] = $where + ['grund' => 'unbekannte Objektart'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($row->origin !== 'direkt') {
|
||||
$report['unresolved'][] = $where + ['grund' => 'abgeleitete Zuordnung (wird nicht als direkte übernommen)'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($resolved[$valueId])) {
|
||||
$report['unresolved'][] = $where + ['grund' => 'Wert ohne belastbare Säule'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$config = self::TARGETS[$target];
|
||||
|
||||
if (! DB::table($config['subjects'])->where('id', $row->subject_id)->exists()) {
|
||||
$report['unresolved'][] = $where + ['grund' => 'Objekt nicht mehr vorhanden'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$present = DB::table($config['table'])->where($config['column'], $row->subject_id)->where('pillar_id', $resolved[$valueId])->exists();
|
||||
|
||||
if ($present) {
|
||||
$report['already'][$target]++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $dryRun) {
|
||||
DB::table($config['table'])->insertOrIgnore([$config['column'] => $row->subject_id, 'pillar_id' => $resolved[$valueId]]);
|
||||
}
|
||||
|
||||
$report['copied'][$target]++;
|
||||
}
|
||||
|
||||
$report['mirror'] = array_merge($report['mirror'], $this->mirrorDivergence($dimension->id, $resolved));
|
||||
$report['after'] = $dryRun ? $report['before'] : $this->counts();
|
||||
|
||||
return $report;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $report
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function lines(array $report, bool $dryRun = false): array
|
||||
{
|
||||
$names = ['composition' => 'Module und Programme', 'license_article' => 'Lizenzartikel'];
|
||||
$lines = [$dryRun ? 'Probelauf, es wird nichts geschrieben.' : 'Übernahme abgeschlossen.', ''];
|
||||
|
||||
foreach ($report['mapping'] as $row) {
|
||||
$lines[] = sprintf('Wert %d „%s“ → %s%s', $row['wert_id'], $row['wert'], $row['saeule_id'] === null ? 'keine Säule (offen)' : 'Säule '.$row['saeule_id'].' „'.($row['saeule'] ?? '').'“ ('.$row['status'].')', ! empty($row['hinweis']) ? ' – '.$row['hinweis'] : '');
|
||||
}
|
||||
|
||||
$lines[] = '';
|
||||
|
||||
foreach ($names as $key => $label) {
|
||||
$lines[] = sprintf('%s: %d übernommen, %d bereits vorhanden, Zuordnungen vorher %d, nachher %d', $label, $report['copied'][$key], $report['already'][$key], $report['before'][$key], $report['after'][$key]);
|
||||
}
|
||||
|
||||
$lines[] = sprintf('Medien (nur Information): %d gespiegelte Zeilen, %d nicht mehr in der Medienzuordnung, %d nur dort. Maßgeblich bleibt die Medienzuordnung.', $report['mirror']['element_rows'], $report['mirror']['missing_in_pivot'], $report['mirror']['only_in_pivot']);
|
||||
|
||||
if ($report['unresolved'] === []) {
|
||||
$lines[] = 'Keine ungeklärten Fälle.';
|
||||
} else {
|
||||
$lines[] = '';
|
||||
$lines[] = 'Ungeklärt, bitte entscheiden (nichts wurde geändert):';
|
||||
|
||||
foreach ($report['unresolved'] as $row) {
|
||||
$lines[] = '- '.json_encode($row, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
return $lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Säule zu einem alten Wert, oder der Grund, warum es keine belastbare gibt.
|
||||
*/
|
||||
private function pillarFor(object $value): object|string
|
||||
{
|
||||
if (preg_match('/^pfeiler-(\d+)$/', (string) $value->slug, $match) !== 1) {
|
||||
return 'Kennung ist nicht „pfeiler-<Nummer>“, keine belastbare Verknüpfung';
|
||||
}
|
||||
|
||||
$pillar = DB::table('pillars')->where('id', (int) $match[1])->first();
|
||||
|
||||
if ($pillar === null) {
|
||||
return 'Die Säule zur Kennung existiert nicht mehr';
|
||||
}
|
||||
|
||||
if ($value->pillar_id !== null && (int) $value->pillar_id !== (int) $pillar->id) {
|
||||
return 'Gespeicherte Verknüpfung (Säule '.$value->pillar_id.') und Kennung (Säule '.$pillar->id.') widersprechen sich';
|
||||
}
|
||||
|
||||
if ($pillar->created_at !== null && $value->created_at !== null && $pillar->created_at > $value->created_at) {
|
||||
return 'Die Säule ist jünger als der Wert; die Kennung kann nicht aus ihr entstanden sein';
|
||||
}
|
||||
|
||||
return $pillar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> Objektart wie gespeichert => Ziel
|
||||
*/
|
||||
private function subjectTypes(): array
|
||||
{
|
||||
$types = [];
|
||||
|
||||
foreach ([
|
||||
'composition' => [Composition::class],
|
||||
'license_article' => [LicenseArticle::class],
|
||||
'content_element' => [ContentElement::class],
|
||||
] as $target => $classes) {
|
||||
foreach ($classes as $class) {
|
||||
$types[$class] = $target;
|
||||
$types[(new $class)->getMorphClass()] = $target;
|
||||
}
|
||||
}
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, int>
|
||||
*/
|
||||
private function counts(): array
|
||||
{
|
||||
return [
|
||||
'composition' => DB::table('composition_pillar')->count(),
|
||||
'license_article' => DB::table('license_article_pillar')->count(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, int> $resolved
|
||||
* @return array{missing_in_pivot: int, only_in_pivot: int}
|
||||
*/
|
||||
private function mirrorDivergence(int $dimensionId, array $resolved): array
|
||||
{
|
||||
$mirrored = [];
|
||||
|
||||
foreach (DB::table('identity_dimension_values')
|
||||
->whereIn('subject_type', array_unique([ContentElement::class, (new ContentElement)->getMorphClass()]))
|
||||
->whereIn('editorial_dimension_value_id', array_keys($resolved) ?: [0])
|
||||
->get() as $row) {
|
||||
$mirrored[$row->subject_id.':'.$resolved[(int) $row->editorial_dimension_value_id]] = true;
|
||||
}
|
||||
|
||||
$pivot = [];
|
||||
|
||||
foreach (DB::table('content_element_pillar')->get() as $row) {
|
||||
$pivot[$row->content_element_id.':'.$row->pillar_id] = true;
|
||||
}
|
||||
|
||||
return [
|
||||
'missing_in_pivot' => count(array_diff_key($mirrored, $pivot)),
|
||||
'only_in_pivot' => count(array_diff_key($pivot, $mirrored)),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class LicenseArticle extends Model
|
||||
@@ -49,4 +50,10 @@ public function editorialContentKind(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(EditorialContentKind::class);
|
||||
}
|
||||
|
||||
/** Direkt zugeordnete fachliche Säulen (zentrale Säulenverwaltung). */
|
||||
public function pillars(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Pillar::class)->orderBy('pillars.sort_order')->orderBy('pillars.name');
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,29 @@
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'composition_id',
|
||||
'option_label',
|
||||
];
|
||||
|
||||
/** Komposition, deren öffentliche Seite die Produktseite dieser Lizenzoption ist. */
|
||||
public function composition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Composition::class);
|
||||
}
|
||||
|
||||
/** Bezeichnung der Option auf der Produktseite. */
|
||||
public function optionName(): string
|
||||
{
|
||||
return filled($this->option_label) ? (string) $this->option_label : (string) $this->name;
|
||||
}
|
||||
|
||||
public function versions(): HasMany
|
||||
{
|
||||
return $this->hasMany(OfferVersion::class);
|
||||
|
||||
@@ -22,6 +22,23 @@ public function currentActiveVersion(Offer $offer): OfferVersion
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die aktive, als Kauf angebotene Fassung mit Preis; sonst null (nicht kaufbar, zurückgezogen oder kostenlos).
|
||||
*/
|
||||
public function purchasableVersion(Offer $offer): ?OfferVersion
|
||||
{
|
||||
$version = $offer->versions()
|
||||
->where('status', OfferStatus::Aktiv)
|
||||
->orderByDesc('number')
|
||||
->first();
|
||||
|
||||
if ($version === null || $version->grant_kind !== 'kauf' || $version->price_cents === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $capabilities
|
||||
* @param array<string, mixed> $options
|
||||
@@ -138,6 +155,40 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Zieht die Option aus dem Verkauf zurück: Die aktive Fassung wird beendet und bleibt gespeichert. Bereits
|
||||
* begründete Berechtigungen und Bestellungen ändern sich nicht; offene Warenkörbe zeigen die Position als
|
||||
* zurückgezogen und blockieren den Abschluss, bis der Käufer sie entfernt.
|
||||
*/
|
||||
public function end(Offer $offer): OfferVersion
|
||||
{
|
||||
return DB::transaction(function () use ($offer): OfferVersion {
|
||||
$offer = Offer::query()->lockForUpdate()->findOrFail($offer->id);
|
||||
$version = $this->currentActiveVersion($offer);
|
||||
$version->status = OfferStatus::Beendet;
|
||||
$version->save();
|
||||
|
||||
return $version;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Produktzuordnung der Option: Die Komposition bestimmt die öffentliche Produktseite und die Alternativgruppe,
|
||||
* die Bezeichnung benennt die Option auf dieser Seite. Beides sind keine bindenden Konditionen.
|
||||
*/
|
||||
public function assignProduct(Offer $offer, ?int $compositionId, ?string $optionLabel): Offer
|
||||
{
|
||||
if ($compositionId !== null) {
|
||||
Composition::query()->findOrFail($compositionId);
|
||||
}
|
||||
|
||||
$offer->composition_id = $compositionId;
|
||||
$offer->option_label = filled($optionLabel) ? trim((string) $optionLabel) : null;
|
||||
$offer->save();
|
||||
|
||||
return $offer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
|
||||
@@ -34,6 +34,16 @@ public function pages(): BelongsToMany
|
||||
return $this->belongsToMany(Page::class);
|
||||
}
|
||||
|
||||
public function compositions(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Composition::class);
|
||||
}
|
||||
|
||||
public function licenseArticles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(LicenseArticle::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<Pillar> $query
|
||||
* @return Builder<Pillar>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Alte Filteradressen: Vor der Vereinheitlichung war „Fachliche Säule“ ein Wert der redaktionellen Einordnung
|
||||
* (`?einordnung=…`, `?pillar=…`, `dimension[]=…`). Verweist ein solcher Wert über `pillar_id` auf eine zentrale Säule,
|
||||
* gilt der Filter jetzt für diese Säule, statt stillschweigend zu entfallen.
|
||||
*/
|
||||
final class PillarFilterCompat
|
||||
{
|
||||
/**
|
||||
* @return int|null|false Kennung der Säule; null: alter Säulenwert ohne belastbare Verknüpfung; false: kein Säulenwert
|
||||
*/
|
||||
public static function pillarOfLegacyValue(int $valueId): int|false|null
|
||||
{
|
||||
$row = DB::table('editorial_dimension_values')
|
||||
->join('editorial_dimensions', 'editorial_dimensions.id', '=', 'editorial_dimension_values.editorial_dimension_id')
|
||||
->where('editorial_dimension_values.id', $valueId)
|
||||
->where('editorial_dimensions.slug', EditorialDimension::PILLAR_SLUG)
|
||||
->first(['editorial_dimension_values.pillar_id']);
|
||||
|
||||
if ($row === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $row->pillar_id === null ? null : (int) $row->pillar_id;
|
||||
}
|
||||
}
|
||||
@@ -40,19 +40,55 @@ public function present(Pillar $pillar, string $name, string $slug, ?string $sum
|
||||
|
||||
public function delete(Pillar $pillar): void
|
||||
{
|
||||
if ($pillar->elements()->exists() || $pillar->pages()->exists()) {
|
||||
throw new DomainRuleException('Eine Säule mit zugeordneten Medien oder Seiten wird nicht gelöscht.');
|
||||
$usage = $this->usage($pillar);
|
||||
|
||||
if (array_sum($usage) > 0) {
|
||||
throw new DomainRuleException('Eine Säule mit zugeordneten Objekten wird nicht gelöscht ('.$this->usageText($usage).'). Ordnen Sie sie zuerst anders zu.');
|
||||
}
|
||||
|
||||
$pillar->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $pillarIds
|
||||
* Zuordnungen je Objektart: Medien, Module und Programme, Lizenzartikel, Seiten.
|
||||
*
|
||||
* @return array{medien: int, zusammenstellungen: int, lizenzartikel: int, seiten: int}
|
||||
*/
|
||||
public function assign(ContentElement $element, array $pillarIds): void
|
||||
public function usage(Pillar $pillar): array
|
||||
{
|
||||
$element->pillars()->sync($this->ids($pillarIds));
|
||||
return [
|
||||
'medien' => $pillar->elements()->count(),
|
||||
'zusammenstellungen' => $pillar->compositions()->count(),
|
||||
'lizenzartikel' => $pillar->licenseArticles()->count(),
|
||||
'seiten' => $pillar->pages()->count(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{medien: int, zusammenstellungen: int, lizenzartikel: int, seiten: int} $usage
|
||||
*/
|
||||
public function usageText(array $usage): string
|
||||
{
|
||||
$parts = [];
|
||||
|
||||
foreach (['medien' => ['Medium', 'Medien'], 'zusammenstellungen' => ['Modul oder Programm', 'Module und Programme'], 'lizenzartikel' => ['Lizenzartikel', 'Lizenzartikel'], 'seiten' => ['Seite', 'Seiten']] as $key => [$one, $many]) {
|
||||
if ($usage[$key] > 0) {
|
||||
$parts[] = $usage[$key].' '.($usage[$key] === 1 ? $one : $many);
|
||||
}
|
||||
}
|
||||
|
||||
return $parts === [] ? 'nirgends zugeordnet' : implode(', ', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordnet einem Medium, Modul, Programm, Lizenzartikel oder einer Seite Säulen zu. Alle Objektarten verwenden
|
||||
* dieselbe zentrale Säule und dieselbe Speicherregel; die Zuordnung ersetzt die bisherige vollständig.
|
||||
*
|
||||
* @param list<int|string> $pillarIds
|
||||
*/
|
||||
public function assign(ContentElement|Composition|LicenseArticle|Page $subject, array $pillarIds): void
|
||||
{
|
||||
$subject->pillars()->sync($this->ids($pillarIds));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +96,7 @@ public function assign(ContentElement $element, array $pillarIds): void
|
||||
*/
|
||||
public function assignPages(Page $page, array $pillarIds): void
|
||||
{
|
||||
$page->pillars()->sync($this->ids($pillarIds));
|
||||
$this->assign($page, $pillarIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
* Redaktionsvorschau (Route editorial.card, nur für angemeldete Redaktion); öffentlich nie ausgegeben, weil es
|
||||
* keine Freigabe für die Website hat.
|
||||
* - missing: was für eine vollständige Karte fehlt, als Hinweis nur in der Redaktionsvorschau.
|
||||
* - texts: die zentralen Texte des Fachobjekts, aus denen die Karte einen wählen kann (teaser, summary, description).
|
||||
* summary bleibt der Text der Vorgabe („Automatisch“); texts wird nur gelesen, wenn die Redaktion einen wählt.
|
||||
*/
|
||||
final readonly class CardSubject
|
||||
{
|
||||
@@ -36,24 +38,39 @@ public function __construct(
|
||||
public ?string $previewImage = null,
|
||||
public array $missing = [],
|
||||
public ?string $style = null,
|
||||
public array $texts = [],
|
||||
) {}
|
||||
|
||||
public function withText(?string $title, ?string $summary): self
|
||||
{
|
||||
return new self(
|
||||
title: $title ?? $this->title,
|
||||
summary: $summary ?? $this->summary,
|
||||
kind: $this->kind,
|
||||
badge: $this->badge,
|
||||
meta: $this->meta,
|
||||
url: $this->url,
|
||||
public: $this->public,
|
||||
notice: $this->notice,
|
||||
visual: $this->visual,
|
||||
visualLabel: $this->visualLabel,
|
||||
previewImage: $this->previewImage,
|
||||
missing: $this->missing,
|
||||
style: $this->style,
|
||||
);
|
||||
return $this->copy(['title' => $title ?? $this->title, 'summary' => $summary ?? $this->summary]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Text der Karte aus einem zentralen Text des Fachobjekts. Ist er nicht gepflegt, bleibt die Karte ohne Text
|
||||
* (kein stiller Ersatz aus einem anderen Feld); in der Redaktionsvorschau steht dann ein Hinweis.
|
||||
*/
|
||||
public function withTextChoice(string $field, string $missingHint): self
|
||||
{
|
||||
if (! array_key_exists($field, $this->texts)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$text = $this->texts[$field];
|
||||
$missing = array_values(array_filter($this->missing, fn (string $hint): bool => ! str_contains($hint, 'Kurzbeschreibung')));
|
||||
|
||||
if ($text === null) {
|
||||
$missing[] = $missingHint;
|
||||
}
|
||||
|
||||
return $this->copy(['summary' => $text, 'missing' => $missing]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $changes
|
||||
*/
|
||||
private function copy(array $changes): self
|
||||
{
|
||||
return new self(...array_merge(get_object_vars($this), $changes));
|
||||
}
|
||||
}
|
||||
@@ -265,6 +265,13 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
$profile = app(EditorialProfileReader::class)->read($composition, 'kachel');
|
||||
$summary = $profile->value('teaser') ?: $profile->value('summary');
|
||||
$goal = filled($version?->learning_goal) ? trim((string) $version->learning_goal) : null;
|
||||
// Zentrale Texte, aus denen die Redaktion den Kartentext wählen kann (Zielgruppe „Öffentliche Kachel“).
|
||||
$texts = [
|
||||
'teaser' => $profile->value('teaser'),
|
||||
'summary' => $profile->value('summary'),
|
||||
'description' => $profile->value('description'),
|
||||
'goal' => $goal,
|
||||
];
|
||||
$missing = [];
|
||||
|
||||
if ($summary === null) {
|
||||
@@ -313,6 +320,7 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
visualLabel: $kind,
|
||||
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
||||
missing: $missing,
|
||||
texts: $texts,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,12 @@
|
||||
* öffentlich, mit Verweis auf diese Programmseite, und nur mit bereitgestellter Fassung. Traineranleitungen erscheinen
|
||||
* nie öffentlich (vertraulich für Trainerinnen und Trainer).
|
||||
*
|
||||
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nie:
|
||||
* Beschreibung, Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte, Ausgabeadressen. Das Vorschaubild (Filmstandbild)
|
||||
* der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der Redaktionsvorschau.
|
||||
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Inhaltsart und Ausgabeart sowie einer der Texte
|
||||
* Teaser, Kurzbeschreibung oder ausführliche Beschreibung. Welcher Text erscheint, entscheidet die Redaktion je Karte
|
||||
* (Einstellung „Text der Karte“); ohne Wahl gilt die Kurzbeschreibung, sonst der Teaser. Die ausführliche Beschreibung
|
||||
* erscheint nur, wenn die Redaktion sie ausdrücklich wählt. Nie: Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte,
|
||||
* Ausgabeadressen. Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der
|
||||
* Redaktionsvorschau und kann in der Karte ausdrücklich als Website-Bild übernommen werden (FilmStill).
|
||||
* Eine Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class PublicMaterialReader
|
||||
@@ -124,7 +127,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
||||
|
||||
$shown = clone $element;
|
||||
|
||||
foreach (['working_title', 'display_title', 'summary', 'thumbnail_path', 'thumbnail_alt'] as $field) {
|
||||
foreach (['working_title', 'display_title', 'teaser', 'summary', 'description', 'thumbnail_path', 'thumbnail_alt'] as $field) {
|
||||
if (! array_key_exists($field, $draft)) {
|
||||
continue;
|
||||
}
|
||||
@@ -146,6 +149,18 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
||||
$summary = trim((string) $shown->teaser);
|
||||
}
|
||||
|
||||
$texts = [];
|
||||
|
||||
foreach (['teaser', 'summary', 'description'] as $field) {
|
||||
$own = filled($shown->getAttribute($field)) ? trim((string) $shown->getAttribute($field)) : null;
|
||||
|
||||
if (! array_key_exists($field, $draft) && $profile->origin($field) === 'variante') {
|
||||
$own = $profile->value($field);
|
||||
}
|
||||
|
||||
$texts[$field] = $own;
|
||||
}
|
||||
|
||||
$title = (string) ($shown->display_title ?: $shown->working_title);
|
||||
|
||||
if (! array_key_exists('display_title', $draft) && $profile->origin('display_title') === 'variante') {
|
||||
@@ -184,6 +199,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
||||
previewImage: $previewImage,
|
||||
missing: $missing,
|
||||
style: $film ? 'media' : 'material',
|
||||
texts: $texts,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,10 @@ public function url(mixed $value, bool $preview = false): ?string
|
||||
|
||||
$legacy = self::normalize($value);
|
||||
|
||||
if (is_string($legacy) && WebsiteMediaAlias::isRetired($legacy)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
||||
}
|
||||
|
||||
@@ -175,6 +179,10 @@ public function status(mixed $value): ?array
|
||||
|
||||
$id = $this->elementId($value);
|
||||
|
||||
if ($id === null && WebsiteMediaAlias::isRetired($value)) {
|
||||
return ['public' => false, 'state' => 'missing', 'title' => basename((string) $value), 'note' => 'Das Medium wurde gelöscht.', 'thumb' => null, 'manageUrl' => null];
|
||||
}
|
||||
|
||||
if ($id === null) {
|
||||
return [
|
||||
'public' => true,
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Media\FilmStill;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement mit Anzeigetitel, Kurzbeschreibung, Inhaltsart und
|
||||
@@ -53,7 +57,7 @@ protected function refLabel(): string
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Wählbar sind alle nicht archivierten, nicht gesperrten Filme und Materialien. Öffentlich erscheint die Karte nur mit bereitgestellter Fassung und wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; Traineranleitungen nie. Titel und Kurzbeschreibung pflegen Sie im Medium.';
|
||||
return 'Wählbar sind alle nicht archivierten, nicht gesperrten Filme und Materialien. Öffentlich erscheint die Karte nur mit bereitgestellter Fassung und wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; Traineranleitungen nie. Titel, Teaser, Kurzbeschreibung und Beschreibung pflegen Sie im Medium; welcher Text auf der Karte erscheint, wählen Sie unter „Darstellung“.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
@@ -90,6 +94,57 @@ protected function cardStyle(): string
|
||||
return 'media';
|
||||
}
|
||||
|
||||
/**
|
||||
* Bei einem Film: das Vorschaubild des Films oder eine Stelle des Films als Kartenbild übernehmen. Das Bild wird
|
||||
* einmal als Bild-Medium abgelegt (FilmStill) und wie jedes andere Bild ausgewählt; die Karte liest nur diese Datei.
|
||||
*/
|
||||
protected function imageSourceFields(): array
|
||||
{
|
||||
return [
|
||||
ViewField::make('_filmbild')
|
||||
->label('Bild aus dem Film')
|
||||
->view('filament.cms.filmbild-feld')
|
||||
->dehydrated(false)
|
||||
->visible(fn (Get $get): bool => $this->filmFor($get('element')) !== null)
|
||||
->viewData(function (Get $get): array {
|
||||
$film = $this->filmFor($get('element'));
|
||||
$stills = app(FilmStill::class);
|
||||
$version = $film instanceof ContentElement ? $stills->version($film) : null;
|
||||
|
||||
return [
|
||||
'film' => $film,
|
||||
'filmTitle' => $film instanceof ContentElement ? (string) ($film->display_title ?: $film->working_title) : '',
|
||||
'filmVersionId' => $version?->id,
|
||||
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
||||
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
|
||||
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
||||
];
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
private function filmFor(mixed $id): ?ContentElement
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $element instanceof ContentElement && app(FilmStill::class)->refusal($element) === null ? $element : null;
|
||||
}
|
||||
|
||||
protected function subjectNoun(): string
|
||||
{
|
||||
return 'Medium';
|
||||
}
|
||||
|
||||
protected function textChoices(): array
|
||||
{
|
||||
return [
|
||||
'auto' => 'Automatisch (Kurzbeschreibung, sonst Teaser)',
|
||||
'teaser' => 'Teaser',
|
||||
'summary' => 'Kurzbeschreibung',
|
||||
'description' => 'Ausführliche Beschreibung (erscheint öffentlich)',
|
||||
];
|
||||
}
|
||||
|
||||
protected function centralCoverId(mixed $id): ?int
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Field;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Group;
|
||||
@@ -56,6 +57,47 @@ abstract protected function defaultActionLabel(): string;
|
||||
/** Gestaltungsvariante des Kits: editorial, media oder catalog. */
|
||||
abstract protected function cardStyle(): string;
|
||||
|
||||
/**
|
||||
* Weitere Wege zum Kartenbild im Reiter „Medien“, zum Beispiel ein Bild aus dem Film. Standard: keine.
|
||||
*
|
||||
* @return list<Field>
|
||||
*/
|
||||
protected function imageSourceFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Zentrale Texte des Fachobjekts, aus denen die Redaktion den Kartentext wählen kann: Wert => Bezeichnung.
|
||||
* Leer: keine Wahl (die Karte nimmt den Text ihrer Vorgabe). Mit Wahl gilt „auto“ als Vorgabe.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function textChoices(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/** Was die Redaktion bearbeitet, um einen Text zu pflegen („Medium“, „Programm oder Modul“); für Hinweise. */
|
||||
protected function subjectNoun(): string
|
||||
{
|
||||
return 'Objekt';
|
||||
}
|
||||
|
||||
/** Hinweis der Redaktionsvorschau, wenn der gewählte zentrale Text nicht gepflegt ist. */
|
||||
private function missingTextHint(string $field): string
|
||||
{
|
||||
$noun = $this->subjectNoun();
|
||||
|
||||
return match ($field) {
|
||||
'teaser' => 'Kein Teaser gepflegt ('.$noun.' bearbeiten → Teaser).',
|
||||
'summary' => 'Keine Kurzbeschreibung gepflegt ('.$noun.' bearbeiten → Kurzbeschreibung).',
|
||||
'description' => 'Keine ausführliche Beschreibung gepflegt ('.$noun.' bearbeiten → Beschreibung).',
|
||||
'goal' => 'Kein Lernziel gepflegt ('.$noun.' bearbeiten → Lernziel der Fassung).',
|
||||
default => '',
|
||||
};
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'widgets.premium_card';
|
||||
@@ -110,7 +152,9 @@ public function optionIcons(): array
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
$choices = $this->textChoices();
|
||||
|
||||
return ($choices === [] ? [] : ['text_source' => $choices]) + [
|
||||
'format' => ['landscape' => 'Querformat 16:9', 'square' => 'Quadrat 1:1', 'portrait' => 'Hochformat 3:4'],
|
||||
'fit' => ['cover' => 'Ausschnitt füllt die Fläche', 'contain' => 'Ganzes Bild zeigen (Dokument, Poster)'],
|
||||
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
||||
@@ -124,10 +168,11 @@ public function settings(): array
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'text_source' => ['Text der Karte', 'Welche Angabe aus der Redaktion die Karte zeigt. Vorgabe: Automatisch. Der gewählte Text erscheint öffentlich, wenn die Karte öffentlich ist; ist er nicht gepflegt, bleibt die Karte ohne Text.'],
|
||||
'format' => ['Bildformat', 'Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
||||
'fit' => ['Bilddarstellung', 'Vorgabe: Ausschnitt. „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Vorgabe: H3, passend unter einer Abschnittsüberschrift (H2).'],
|
||||
'show_summary' => ['Kurzbeschreibung', 'Aus den Fachdaten. Vorgabe: anzeigen.'],
|
||||
'show_summary' => ['Text anzeigen', 'Aus den Fachdaten. Vorgabe: anzeigen.'],
|
||||
'show_kind' => ['Art oder Label', 'Zum Beispiel „Thema“ oder „Merkblatt“. Vorgabe: anzeigen.'],
|
||||
'show_meta' => ['Zusatzangaben', 'Aus den Fachdaten, zum Beispiel Ausgabeart oder Programmzugehörigkeit. Vorgabe: anzeigen.'],
|
||||
'show_action' => ['Aktion', 'Verweis auf die öffentliche Seite des Fachobjekts, falls es eine gibt. Vorgabe: anzeigen.'],
|
||||
@@ -195,13 +240,13 @@ public function editorSchema(): array
|
||||
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
|
||||
->helperText('Leer übernimmt den Anzeigenamen des Fachobjekts. Eine Eintragung gilt nur für diese Karte und ändert die Quelle nicht.'),
|
||||
TextInput::make('summary')
|
||||
->label('Teaser nur für diese Karte')
|
||||
->label('Text nur für diese Karte')
|
||||
->maxLength(500)
|
||||
->live(onBlur: true)
|
||||
->placeholder(fn (Get $get): string => $this->centralText($get('../refs.'.$this->refKey()), 'summary') ?? 'Zentraler Teaser oder Kurzbeschreibung')
|
||||
->placeholder(fn (Get $get): string => $this->centralText($get('../refs.'.$this->refKey()), 'summary', $get('../settings.text_source')) ?? 'Zentraler Text aus der Redaktion')
|
||||
->hint(fn (?string $state): string => filled($state) ? 'Eigene Angabe für diese Karte' : 'Aus der Redaktion')
|
||||
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
|
||||
->helperText('Leer übernimmt Teaser oder Kurzbeschreibung. Lehrinhalt, Rechte und Preise bleiben unberührt.'),
|
||||
->helperText('Leer übernimmt den Text, den „Text der Karte“ (Darstellung) wählt. Lehrinhalt, Rechte und Preise bleiben unberührt.'),
|
||||
])->statePath('data'),
|
||||
];
|
||||
}
|
||||
@@ -211,7 +256,7 @@ public function mediaSchema(): array
|
||||
[, , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make(ImageRefFields::fields('Kartenbild', live: true))->statePath('refs'),
|
||||
Group::make([...ImageRefFields::fields('Kartenbild', live: true), ...$this->imageSourceFields()])->statePath('refs'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
];
|
||||
}
|
||||
@@ -248,6 +293,12 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
$data = $widget['data'];
|
||||
|
||||
$subject = $this->subject($widget['refs'][$this->refKey()] ?? null, $context);
|
||||
$textSource = $option('text_source', 'auto');
|
||||
|
||||
if ($subject instanceof CardSubject && $textSource !== 'auto' && isset($this->textChoices()[$textSource])) {
|
||||
$subject = $subject->withTextChoice($textSource, $this->missingTextHint($textSource));
|
||||
}
|
||||
|
||||
$heading = filled($data['heading'] ?? null) ? trim((string) $data['heading']) : null;
|
||||
$lead = filled($data['summary'] ?? null) ? trim((string) $data['summary']) : null;
|
||||
|
||||
@@ -302,7 +353,7 @@ protected function centralCoverId(mixed $id): ?int
|
||||
/**
|
||||
* Zentraler Anzeigename oder Teaser des gewählten Objekts (Redaktionsstand) für Platzhalter im Editor.
|
||||
*/
|
||||
private function centralText(mixed $id, string $field): ?string
|
||||
private function centralText(mixed $id, string $field, mixed $textSource = null): ?string
|
||||
{
|
||||
if (blank($id)) {
|
||||
return null;
|
||||
@@ -314,6 +365,10 @@ private function centralText(mixed $id, string $field): ?string
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($subject instanceof CardSubject && is_string($textSource) && isset($this->textChoices()[$textSource]) && $textSource !== 'auto') {
|
||||
$subject = $subject->withTextChoice($textSource, $this->missingTextHint($textSource));
|
||||
}
|
||||
|
||||
$text = $subject?->{$field};
|
||||
|
||||
return is_string($text) && trim($text) !== '' ? Str::limit(trim($text), 120) : null;
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Media\CompositionStill;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
/**
|
||||
* Modul- und Programmkarte (Kit v1.7 „catalog“): ein Programm oder Modul über PublicCatalogReader, dieselbe
|
||||
@@ -41,6 +45,59 @@ public function schematic(): array
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'ink'], [8, 24, 10, 2, 'accent'], [31, 8, 10, 2, 'line'], [31, 13, 22, 4, 'ink'], [31, 25, 14, 5, 'ink']];
|
||||
}
|
||||
|
||||
/**
|
||||
* Das Vorschaubild des Programms oder Moduls als Kartenbild übernehmen. Es wird einmal als Bild-Medium abgelegt
|
||||
* (CompositionStill) und wie jedes andere Bild ausgewählt; die Karte liest nur diese Datei.
|
||||
*/
|
||||
protected function imageSourceFields(): array
|
||||
{
|
||||
return [
|
||||
ViewField::make('_programmbild')
|
||||
->label('Bild aus dem Programm oder Modul')
|
||||
->view('filament.cms.kompositionsbild-feld')
|
||||
->dehydrated(false)
|
||||
->visible(fn (Get $get): bool => $this->compositionFor($get('composition')) !== null)
|
||||
->viewData(function (Get $get): array {
|
||||
$composition = $this->compositionFor($get('composition'));
|
||||
|
||||
return [
|
||||
'composition' => $composition,
|
||||
'compositionTitle' => $composition instanceof Composition ? (string) ($composition->display_title ?: $composition->designation) : '',
|
||||
'compositionThumbnailUrl' => $composition instanceof Composition && app(CompositionStill::class)->hasThumbnail($composition)
|
||||
? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path)
|
||||
: null,
|
||||
];
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
private function compositionFor(mixed $id): ?Composition
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $composition instanceof Composition && app(PublicCatalogReader::class)->isCardSelectable($composition) ? $composition : null;
|
||||
}
|
||||
|
||||
protected function subjectNoun(): string
|
||||
{
|
||||
return 'Programm oder Modul';
|
||||
}
|
||||
|
||||
/**
|
||||
* Wählbare Texte: die zentralen Texte des Programms oder Moduls und das Lernziel der Fassung. „Automatisch“ bleibt
|
||||
* wie bisher: Teaser, sonst Kurzbeschreibung, sonst Lernziel. Die ausführliche Beschreibung erscheint nur auf Wahl.
|
||||
*/
|
||||
protected function textChoices(): array
|
||||
{
|
||||
return [
|
||||
'auto' => 'Automatisch (Teaser, sonst Kurzbeschreibung, sonst Lernziel)',
|
||||
'teaser' => 'Teaser',
|
||||
'summary' => 'Kurzbeschreibung',
|
||||
'description' => 'Ausführliche Beschreibung (erscheint öffentlich)',
|
||||
'goal' => 'Lernziel der Fassung',
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
// Die Art (Programm oder Modul) bleibt immer sichtbar; sie lässt sich nicht ausblenden.
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Domain\Identity\PartyType;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Sitzungsgebundener Mehrangebotswarenkorb (Etappe 1). Er bleibt in derselben Browsersitzung über Anmeldung,
|
||||
* Registrierung und E-Mail-Bestätigung erhalten. Je Option gibt es genau eine Position. Optionen derselben Produktseite
|
||||
* (gleiche Komposition) sind Alternativen und werden nur nach ausdrücklichem Wechsel ersetzt.
|
||||
* Der Warenkorb reserviert weder Preis noch Konditionen; er merkt sich, was der Käufer gesehen hat.
|
||||
*/
|
||||
class Cart
|
||||
{
|
||||
public const KEY = 'shop.cart';
|
||||
|
||||
public const ADDED = 'added';
|
||||
|
||||
public const PRESENT = 'present';
|
||||
|
||||
public const ALTERNATIVE = 'alternative';
|
||||
|
||||
public const UNAVAILABLE = 'unavailable';
|
||||
|
||||
public function __construct(
|
||||
private readonly OwnershipCheck $ownership,
|
||||
private readonly OrderHolders $holders,
|
||||
private readonly OfferService $offers,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return array<int, array{version_id: int, price_cents: int}>
|
||||
*/
|
||||
public function items(): array
|
||||
{
|
||||
return (array) session()->get(self::KEY, []);
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->items());
|
||||
}
|
||||
|
||||
public function has(Offer $offer): bool
|
||||
{
|
||||
return isset($this->items()[$offer->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Die bereits enthaltene Alternative derselben Produktseite, falls vorhanden.
|
||||
*/
|
||||
public function alternativeTo(Offer $offer): ?Offer
|
||||
{
|
||||
if ($offer->composition_id === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ids = array_diff(array_keys($this->items()), [$offer->id]);
|
||||
|
||||
return $ids === [] ? null : Offer::query()
|
||||
->whereIn('id', $ids)
|
||||
->where('composition_id', $offer->composition_id)
|
||||
->first();
|
||||
}
|
||||
|
||||
public function add(Offer $offer): string
|
||||
{
|
||||
$version = $this->purchasable($offer);
|
||||
|
||||
if ($version === null) {
|
||||
return self::UNAVAILABLE;
|
||||
}
|
||||
|
||||
if ($this->has($offer)) {
|
||||
return self::PRESENT;
|
||||
}
|
||||
|
||||
if ($this->alternativeTo($offer) !== null) {
|
||||
return self::ALTERNATIVE;
|
||||
}
|
||||
|
||||
$this->put($offer, $version);
|
||||
|
||||
return self::ADDED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ausdrücklicher Wechsel: die Alternative wird durch die gewählte Option ersetzt.
|
||||
*/
|
||||
public function switchTo(Offer $offer): bool
|
||||
{
|
||||
$version = $this->purchasable($offer);
|
||||
|
||||
if ($version === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$alternative = $this->alternativeTo($offer);
|
||||
|
||||
if ($alternative !== null) {
|
||||
$this->remove($alternative);
|
||||
}
|
||||
|
||||
$this->put($offer, $version);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function remove(Offer $offer): void
|
||||
{
|
||||
$items = $this->items();
|
||||
unset($items[$offer->id]);
|
||||
session()->put(self::KEY, $items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Käufer übernimmt Preis und Fassung, die der Shop jetzt zeigt.
|
||||
*/
|
||||
public function acceptCurrent(Offer $offer): void
|
||||
{
|
||||
$version = $this->purchasable($offer);
|
||||
|
||||
if ($version !== null && $this->has($offer)) {
|
||||
$this->put($offer, $version);
|
||||
}
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
session()->forget(self::KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serverseitige Prüfung: aktuelle Fassung, Preis, Kaufbarkeit, passende Inhaberart, vorhandene Rechte.
|
||||
*/
|
||||
public function review(?User $user = null, ?int $holderPartyId = null): CartReview
|
||||
{
|
||||
$offers = Offer::query()
|
||||
->whereIn('id', array_keys($this->items()))
|
||||
->with('composition')
|
||||
->get()
|
||||
->keyBy('id');
|
||||
$versions = [];
|
||||
|
||||
foreach ($this->items() as $offerId => $item) {
|
||||
$offer = $offers->get($offerId);
|
||||
|
||||
if ($offer !== null) {
|
||||
$versions[$offerId] = $this->purchasable($offer);
|
||||
}
|
||||
}
|
||||
|
||||
$holder = $user === null ? null : $this->holderFor($user, $holderPartyId, $versions);
|
||||
$lines = [];
|
||||
|
||||
foreach ($this->items() as $offerId => $item) {
|
||||
$offer = $offers->get($offerId);
|
||||
|
||||
if ($offer === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$version = $versions[$offerId] ?? null;
|
||||
$seen = (int) $item['price_cents'];
|
||||
|
||||
if ($version === null) {
|
||||
$lines[] = new CartLine($offer, null, CartLine::WITHDRAWN, $seen, null,
|
||||
'Diese Option ist nicht mehr erhältlich. Entferne sie, um mit den übrigen Positionen fortzufahren.');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$current = (int) $version->price_cents;
|
||||
|
||||
if ($holder !== null && ! $this->suitsHolder($version, $holder)) {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::WRONG_HOLDER, $seen, $current,
|
||||
$version->holder_kind === 'organisation'
|
||||
? 'Diese Option ist für Organisationen. Bestelle als Verein oder entferne sie.'
|
||||
: 'Diese Option ist für Privatpersonen. Bestelle als Privatperson oder entferne sie.');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($holder !== null && $this->ownership->covers($holder, $version)) {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::OWNED, $seen, $current);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($current !== $seen) {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::PRICE_CHANGED, $seen, $current);
|
||||
} elseif ((int) $item['version_id'] !== $version->id) {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::TERMS_CHANGED, $seen, $current,
|
||||
'Die Bedingungen dieser Option wurden aktualisiert. Bitte prüfe die Übersicht.');
|
||||
} else {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::OK, $seen, $current);
|
||||
}
|
||||
}
|
||||
|
||||
return new CartReview($lines, $holder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Die aktive, als Kauf angebotene Fassung der Option; sonst null (nicht kaufbar oder zurückgezogen).
|
||||
*/
|
||||
public function purchasable(Offer $offer): ?OfferVersion
|
||||
{
|
||||
return $this->offers->purchasableVersion($offer);
|
||||
}
|
||||
|
||||
private function put(Offer $offer, OfferVersion $version): void
|
||||
{
|
||||
$items = $this->items();
|
||||
$items[$offer->id] = ['version_id' => $version->id, 'price_cents' => (int) $version->price_cents];
|
||||
session()->put(self::KEY, $items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, OfferVersion|null> $versions
|
||||
*/
|
||||
private function holderFor(User $user, ?int $partyId, array $versions): ?Party
|
||||
{
|
||||
$onlyOrganisations = $versions !== [] && collect($versions)
|
||||
->filter()
|
||||
->every(fn (OfferVersion $version): bool => $version->holder_kind === 'organisation');
|
||||
|
||||
try {
|
||||
return $this->holders->resolve($user, $partyId, $onlyOrganisations);
|
||||
} catch (DomainRuleException) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function suitsHolder(OfferVersion $version, Party $holder): bool
|
||||
{
|
||||
return ($version->holder_kind === 'organisation') === ($holder->type === PartyType::Organisation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
|
||||
/**
|
||||
* Eine Position des Warenkorbs mit dem Ergebnis der serverseitigen Prüfung.
|
||||
*/
|
||||
final class CartLine
|
||||
{
|
||||
public const OK = 'ok';
|
||||
|
||||
public const PRICE_CHANGED = 'preis_geaendert';
|
||||
|
||||
public const TERMS_CHANGED = 'bedingungen_geaendert';
|
||||
|
||||
public const WITHDRAWN = 'zurueckgezogen';
|
||||
|
||||
public const OWNED = 'bereits_erworben';
|
||||
|
||||
public const WRONG_HOLDER = 'falscher_inhaber';
|
||||
|
||||
public function __construct(
|
||||
public readonly Offer $offer,
|
||||
public readonly ?OfferVersion $version,
|
||||
public readonly string $state,
|
||||
public readonly int $seenPriceCents,
|
||||
public readonly ?int $currentPriceCents,
|
||||
public readonly ?string $note = null,
|
||||
) {}
|
||||
|
||||
/** Geht in Summe und Bestellung ein. */
|
||||
public function orderable(): bool
|
||||
{
|
||||
return in_array($this->state, [self::OK, self::PRICE_CHANGED, self::TERMS_CHANGED], true);
|
||||
}
|
||||
|
||||
/** Verhindert den Abschluss, bis der Käufer die Position selbst entfernt oder den Inhaber wechselt. */
|
||||
public function blocks(): bool
|
||||
{
|
||||
return in_array($this->state, [self::WITHDRAWN, self::WRONG_HOLDER], true);
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
$composition = $this->offer->composition;
|
||||
|
||||
return $composition !== null
|
||||
? (string) ($composition->display_title ?: $composition->designation)
|
||||
: (string) $this->offer->name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Identity\Party;
|
||||
|
||||
/**
|
||||
* Prüfergebnis des Warenkorbs für einen vorgesehenen Lizenzinhaber. Die Prüfsumme bindet die Bestellung an genau
|
||||
* diese Übersicht: Inhaber, Fassung und Preis jeder Position samt Zustand, auch der ausgeschlossenen.
|
||||
*/
|
||||
final class CartReview
|
||||
{
|
||||
/**
|
||||
* @param list<CartLine> $lines
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly array $lines,
|
||||
public readonly ?Party $holder,
|
||||
) {}
|
||||
|
||||
/** @return list<CartLine> */
|
||||
public function orderable(): array
|
||||
{
|
||||
return array_values(array_filter($this->lines, fn (CartLine $line): bool => $line->orderable()));
|
||||
}
|
||||
|
||||
public function totalCents(): int
|
||||
{
|
||||
return array_sum(array_map(fn (CartLine $line): int => (int) $line->currentPriceCents, $this->orderable()));
|
||||
}
|
||||
|
||||
public function blocked(): bool
|
||||
{
|
||||
foreach ($this->lines as $line) {
|
||||
if ($line->blocks()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function empty(): bool
|
||||
{
|
||||
return $this->orderable() === [];
|
||||
}
|
||||
|
||||
public function canOrder(): bool
|
||||
{
|
||||
return $this->holder !== null && ! $this->blocked() && ! $this->empty();
|
||||
}
|
||||
|
||||
public function digest(): string
|
||||
{
|
||||
$parts = [];
|
||||
|
||||
foreach ($this->lines as $line) {
|
||||
$parts[] = $line->offer->id.':'.($line->version?->id ?? 0).':'.$line->currentPriceCents.':'.$line->state;
|
||||
}
|
||||
|
||||
sort($parts);
|
||||
|
||||
return hash('sha256', ($this->holder?->id ?? 0).'|'.implode(',', $parts));
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,13 @@
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Entitlement\Acquisition;
|
||||
use App\Domain\Entitlement\AcquisitionType;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Identity\AccountStatus;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Mail\OrderConfirmed;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -20,13 +22,15 @@ class Checkout
|
||||
public function __construct(
|
||||
private readonly GrantIssuer $grants,
|
||||
private readonly OfferService $offers,
|
||||
private readonly OrderHolders $holders,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Einzelkauf einer Option als Person (bestehender Weg, ohne Warenkorb).
|
||||
*/
|
||||
public function place(User $user, Offer $offer): Order
|
||||
{
|
||||
if ($user->status !== AccountStatus::Aktiv || $user->party_id === null) {
|
||||
throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
|
||||
}
|
||||
$this->assertActive($user);
|
||||
|
||||
$version = $this->offers->currentActiveVersion($offer);
|
||||
|
||||
@@ -38,20 +42,78 @@ public function place(User $user, Offer $offer): Order
|
||||
throw new DomainRuleException('Der Kauf braucht einen Preis an der Angebotsfassung.');
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($user, $offer, $version): Order {
|
||||
$order = Order::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'party_id' => $user->party_id,
|
||||
'status' => 'offen',
|
||||
'holder_kind' => 'person',
|
||||
]);
|
||||
$holder = $this->holders->resolve($user, null);
|
||||
|
||||
return DB::transaction(fn (): Order => $this->createOrder($user, $holder, [[$offer, $version]]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestellung aus dem Warenkorb, erst nach serverseitiger Prüfung. Die Prüfsumme bindet die Bestellung an die
|
||||
* Übersicht, die der Käufer gesehen hat: Hat sich Preis, Fassung oder Bedingung seither geändert, entsteht keine
|
||||
* Bestellung und der Käufer sieht zuerst die aktualisierte Übersicht. Positionen, deren Umfang der Inhaber bereits
|
||||
* mit denselben Rechten besitzt, erzeugen keine Bestellposition.
|
||||
*/
|
||||
public function placeFromCart(User $user, Cart $cart, ?int $holderPartyId, string $digest): Order
|
||||
{
|
||||
$this->assertActive($user);
|
||||
|
||||
$order = DB::transaction(function () use ($user, $cart, $holderPartyId, $digest): Order {
|
||||
// Optionen sperren, damit eine gleichzeitige Aktivierung die Prüfung nicht unterläuft.
|
||||
Offer::query()->whereIn('id', array_keys($cart->items()))->orderBy('id')->lockForUpdate()->get();
|
||||
$review = $cart->review($user, $holderPartyId);
|
||||
|
||||
if ($review->holder === null) {
|
||||
throw new DomainRuleException('Für diesen Lizenzinhaber ist das Konto nicht bestellberechtigt.');
|
||||
}
|
||||
|
||||
if (! hash_equals($review->digest(), $digest)) {
|
||||
throw new StaleOverview('Die Übersicht hat sich geändert. Bitte prüfe die aktualisierte Bestellübersicht.');
|
||||
}
|
||||
|
||||
if ($review->blocked()) {
|
||||
throw new DomainRuleException('Entferne zuerst die Positionen, die nicht bestellt werden können.');
|
||||
}
|
||||
|
||||
if ($review->empty()) {
|
||||
throw new DomainRuleException('Es gibt nichts zu bestellen. Alle Positionen sind bereits erworben.');
|
||||
}
|
||||
|
||||
$pairs = array_map(fn (CartLine $line): array => [$line->offer, $line->version], $review->orderable());
|
||||
|
||||
return $this->createOrder($user, $review->holder, $pairs);
|
||||
});
|
||||
|
||||
$cart->clear();
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array{0: Offer, 1: OfferVersion}> $pairs
|
||||
*/
|
||||
private function createOrder(User $user, Party $holder, array $pairs): Order
|
||||
{
|
||||
$order = Order::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'party_id' => $holder->id,
|
||||
'status' => 'offen',
|
||||
'holder_kind' => $holder->type->value,
|
||||
'total_cents' => array_sum(array_map(fn (array $pair): int => (int) $pair[1]->price_cents, $pairs)),
|
||||
'currency' => 'EUR',
|
||||
]);
|
||||
|
||||
foreach ($pairs as [$offer, $version]) {
|
||||
$line = $order->lines()->create([
|
||||
'offer_version_id' => $version->id,
|
||||
'offer_name' => $offer->name,
|
||||
'price_cents' => $version->price_cents,
|
||||
'currency' => 'EUR',
|
||||
'term_rule' => $version->term_rule,
|
||||
'update_promise' => $version->update_promise,
|
||||
'holder_kind' => $version->holder_kind,
|
||||
'tax_class' => $version->tax_class,
|
||||
'grant_kind' => $version->grant_kind,
|
||||
'holder_party_id' => $holder->id,
|
||||
]);
|
||||
$version->load('resolvedScopes.rights');
|
||||
|
||||
@@ -66,11 +128,15 @@ public function place(User $user, Offer $offer): Order
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $order->load('lines.scopeItems');
|
||||
});
|
||||
return $order->load('lines.scopeItems');
|
||||
}
|
||||
|
||||
/**
|
||||
* Freischaltung nach bestätigter Testzahlung: alle Bestellpositionen aus ihrem festgehaltenen Umfang, in einer
|
||||
* Transaktion. Wiederholte Bestätigung ist wirkungslos; ein Fehler hinterlässt weder Zahlung noch Rechte.
|
||||
*/
|
||||
public function confirmTestPayment(Order $order, string $reference): Order
|
||||
{
|
||||
$this->assertTestDriver();
|
||||
@@ -100,14 +166,12 @@ public function confirmTestPayment(Order $order, string $reference): Order
|
||||
$order->status = 'bezahlt';
|
||||
$order->save();
|
||||
$paidNow = true;
|
||||
$line = $order->lines()->firstOrFail();
|
||||
$this->grants->issue(
|
||||
$order->user,
|
||||
$line->offerVersion,
|
||||
AcquisitionType::Bestellposition,
|
||||
'order_line',
|
||||
$line->id,
|
||||
);
|
||||
$actor = User::query()->findOrFail($order->user_id);
|
||||
|
||||
foreach ($order->lines()->orderBy('id')->get() as $line) {
|
||||
$holder = Party::query()->findOrFail($line->holder_party_id ?? $order->party_id);
|
||||
$this->grants->issueFromOrderLine($line, $holder, $actor);
|
||||
}
|
||||
|
||||
return $order->load('lines', 'payments');
|
||||
});
|
||||
@@ -142,6 +206,10 @@ public function failTestPayment(Order $order, string $reference): Order
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Vollerstattung: widerruft die Berechtigungen aller Positionen dieser Bestellung. Andere Erwerbsquellen
|
||||
* (kostenlose Vergabe, frühere Käufe) bleiben unberührt.
|
||||
*/
|
||||
public function refund(Order $order, string $reason): Order
|
||||
{
|
||||
$reason = trim($reason);
|
||||
@@ -157,15 +225,14 @@ public function refund(Order $order, string $reason): Order
|
||||
throw new DomainRuleException('Nur eine bezahlte Bestellung kann erstattet werden.');
|
||||
}
|
||||
|
||||
$line = $order->lines()->firstOrFail();
|
||||
$acquisition = Acquisition::query()->where([
|
||||
'type' => AcquisitionType::Bestellposition,
|
||||
'reference_type' => 'order_line',
|
||||
'reference_id' => $line->id,
|
||||
])->first();
|
||||
foreach ($order->lines()->orderBy('id')->get() as $line) {
|
||||
$acquisition = Acquisition::query()->where([
|
||||
'type' => AcquisitionType::Bestellposition,
|
||||
'reference_type' => 'order_line',
|
||||
'reference_id' => $line->id,
|
||||
])->first();
|
||||
|
||||
if ($acquisition !== null) {
|
||||
foreach ($acquisition->grants as $grant) {
|
||||
foreach ($acquisition?->grants ?? [] as $grant) {
|
||||
if ($grant->status === GrantStatus::Aktiv) {
|
||||
$grant->status = GrantStatus::Widerrufen;
|
||||
$grant->status_reason = $reason;
|
||||
@@ -182,6 +249,13 @@ public function refund(Order $order, string $reason): Order
|
||||
});
|
||||
}
|
||||
|
||||
private function assertActive(User $user): void
|
||||
{
|
||||
if ($user->status !== AccountStatus::Aktiv || $user->party_id === null) {
|
||||
throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
|
||||
}
|
||||
}
|
||||
|
||||
private function assertTestDriver(): void
|
||||
{
|
||||
if (app()->isProduction() || config('services.payment.driver') !== 'test') {
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
|
||||
/**
|
||||
* Beträge werden als ganze Cent gespeichert und in Euro angezeigt und eingegeben (deutsches Format).
|
||||
*/
|
||||
final class Money
|
||||
{
|
||||
/** Obergrenze eines Preises (1.000.000 €), weit unter dem Wertebereich der Datenbank. */
|
||||
public const MAX_CENTS = 100_000_000;
|
||||
|
||||
public static function format(?int $cents): string
|
||||
{
|
||||
return $cents === null ? '–' : number_format($cents / 100, 2, ',', '.').' €';
|
||||
}
|
||||
|
||||
/**
|
||||
* Euro-Eingabe („12,50“, „1.299“, „5“) als Cent. Leere Eingabe ergibt null.
|
||||
*/
|
||||
public static function parse(string|int|float|null $input): ?int
|
||||
{
|
||||
if ($input === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$text = trim((string) $input);
|
||||
|
||||
if ($text === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$text = str_replace([' ', '€'], '', $text);
|
||||
|
||||
if (str_contains($text, ',')) {
|
||||
$text = str_replace('.', '', $text);
|
||||
$text = str_replace(',', '.', $text);
|
||||
} elseif (preg_match('/^\d{1,3}(\.\d{3})+$/', $text) === 1) {
|
||||
$text = str_replace('.', '', $text);
|
||||
}
|
||||
|
||||
if (preg_match('/^\d+(\.\d{1,2})?$/', $text) !== 1) {
|
||||
throw new DomainRuleException('Der Preis ist kein gültiger Eurobetrag, zum Beispiel 12,50.');
|
||||
}
|
||||
|
||||
$cents = (int) round(((float) $text) * 100);
|
||||
|
||||
if ($cents > self::MAX_CENTS) {
|
||||
throw new DomainRuleException('Der Preis ist zu hoch. Zulässig sind höchstens '.self::format(self::MAX_CENTS).'.');
|
||||
}
|
||||
|
||||
return $cents;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ class Order extends Model
|
||||
'party_id',
|
||||
'status',
|
||||
'holder_kind',
|
||||
'total_cents',
|
||||
'currency',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Identity\Membership;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Domain\Identity\PartyType;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Für wen ein Konto bestellen darf: für sich selbst (Person) und für Organisationen, bei denen es eine aktive
|
||||
* Mitgliedschaft mit Bestellberechtigung hat. Eine Bestellung hat genau einen Lizenzinhaber.
|
||||
*/
|
||||
class OrderHolders
|
||||
{
|
||||
/**
|
||||
* @return Collection<int, Party>
|
||||
*/
|
||||
public function for(User $user): Collection
|
||||
{
|
||||
$holders = collect();
|
||||
|
||||
if ($user->party_id !== null) {
|
||||
$person = Party::query()->find($user->party_id);
|
||||
|
||||
if ($person !== null) {
|
||||
$holders->push($person);
|
||||
}
|
||||
}
|
||||
|
||||
$organisations = Membership::query()
|
||||
->active()
|
||||
->where('user_id', $user->id)
|
||||
->where('may_order', true)
|
||||
->with('organisation')
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->map(fn (Membership $membership): ?Party => $membership->organisation)
|
||||
->filter(fn (?Party $party): bool => $party !== null && $party->type === PartyType::Organisation);
|
||||
|
||||
return $holders->concat($organisations)->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Der gewählte Inhaber; ohne Wahl die Person, bei Angeboten nur für Organisationen die erste Organisation.
|
||||
*/
|
||||
public function resolve(User $user, ?int $partyId, bool $preferOrganisation = false): Party
|
||||
{
|
||||
$holders = $this->for($user);
|
||||
|
||||
if ($partyId !== null) {
|
||||
$chosen = $holders->first(fn (Party $party): bool => $party->id === $partyId);
|
||||
|
||||
if ($chosen === null) {
|
||||
throw new DomainRuleException('Für diesen Lizenzinhaber ist das Konto nicht bestellberechtigt.');
|
||||
}
|
||||
|
||||
return $chosen;
|
||||
}
|
||||
|
||||
if ($preferOrganisation) {
|
||||
$organisation = $holders->first(fn (Party $party): bool => $party->type === PartyType::Organisation);
|
||||
|
||||
if ($organisation !== null) {
|
||||
return $organisation;
|
||||
}
|
||||
}
|
||||
|
||||
$person = $holders->first(fn (Party $party): bool => $party->type === PartyType::Person);
|
||||
|
||||
return $person ?? throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Identity\Party;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -17,6 +18,10 @@ class OrderLine extends Model
|
||||
'term_rule',
|
||||
'update_promise',
|
||||
'holder_kind',
|
||||
'currency',
|
||||
'tax_class',
|
||||
'grant_kind',
|
||||
'holder_party_id',
|
||||
];
|
||||
|
||||
public function order(): BelongsTo
|
||||
@@ -24,6 +29,11 @@ public function order(): BelongsTo
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
|
||||
public function holder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Party::class, 'holder_party_id');
|
||||
}
|
||||
|
||||
public function offerVersion(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(OfferVersion::class);
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Identity\Party;
|
||||
|
||||
/**
|
||||
* „Bereits erworben“ (FACH-59): Der vorgesehene Lizenzinhaber hat bereits eine gültige Lizenz mit demselben Umfang
|
||||
* und denselben Nutzungsrechten. Maßgeblich ist genau ein Erwerb, der jeden Umfangsposten der Angebotsfassung mit
|
||||
* gleichem Zweck, gleichen Fähigkeiten und gleichen Optionen trägt. Rechte mehrerer Erwerbe werden nicht zu einer
|
||||
* neuen Lizenz kombiniert. Alle Erwerbsarten zählen (Kauf, freier Abruf, manuelle Vergabe), sofern aktiv und gültig.
|
||||
*/
|
||||
class OwnershipCheck
|
||||
{
|
||||
public function covers(Party $holder, OfferVersion $version): bool
|
||||
{
|
||||
$needed = $this->needed($version);
|
||||
|
||||
if ($needed === []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$now = now();
|
||||
$byAcquisition = Grant::query()
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $holder->id))
|
||||
->get()
|
||||
->filter(fn (Grant $grant): bool => ($grant->valid_from === null || ! $grant->valid_from->greaterThan($now))
|
||||
&& ($grant->valid_until === null || $grant->valid_until->greaterThan($now)))
|
||||
->groupBy('acquisition_id');
|
||||
|
||||
foreach ($byAcquisition as $grants) {
|
||||
$have = [];
|
||||
|
||||
foreach ($grants as $grant) {
|
||||
$have[$grant->license_article_id.'|'.$this->fingerprint($grant->rights_snapshot ?? [])] = true;
|
||||
}
|
||||
|
||||
if (array_diff_key($needed, $have) === []) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, true>
|
||||
*/
|
||||
private function needed(OfferVersion $version): array
|
||||
{
|
||||
$needed = [];
|
||||
$version->loadMissing('resolvedScopes.rights');
|
||||
|
||||
foreach ($version->resolvedScopes as $scope) {
|
||||
$needed[$scope->license_article_id.'|'.$this->fingerprint([
|
||||
'purpose' => $scope->rights->purpose,
|
||||
'capabilities' => $scope->rights->capabilities,
|
||||
'options' => $scope->rights->options ?? [],
|
||||
])] = true;
|
||||
}
|
||||
|
||||
return $needed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reihenfolge von Schlüsseln und Aktionen spielt keine Rolle.
|
||||
*
|
||||
* @param array<string, mixed> $rights
|
||||
*/
|
||||
private function fingerprint(array $rights): string
|
||||
{
|
||||
$capabilities = [];
|
||||
|
||||
foreach ((array) ($rights['capabilities'] ?? []) as $class => $actions) {
|
||||
$actions = array_values(array_unique((array) $actions));
|
||||
sort($actions);
|
||||
$capabilities[(string) $class] = $actions;
|
||||
}
|
||||
|
||||
ksort($capabilities);
|
||||
$options = (array) ($rights['options'] ?? []);
|
||||
ksort($options);
|
||||
|
||||
return md5(json_encode([
|
||||
'purpose' => (string) ($rights['purpose'] ?? ''),
|
||||
'capabilities' => $capabilities,
|
||||
'options' => $options,
|
||||
], JSON_THROW_ON_ERROR));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
|
||||
/**
|
||||
* Kaufbare Lizenzoptionen einer Produktseite aus dem veröffentlichten Katalog: aktive Angebotsfassungen mit Preis,
|
||||
* Eignung, Laufzeit, Umfang und Nutzungsrechten. Die Seite selbst (Titel, Beschreibung, Struktur) kommt aus der
|
||||
* zur Anzeige freigegebenen Komposition; hier entsteht kein zweiter Text.
|
||||
*/
|
||||
class ProductOptions
|
||||
{
|
||||
public function __construct(private readonly OfferService $offers) {}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function forComposition(Composition $composition): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (Offer::query()->where('composition_id', $composition->id)->orderBy('id')->get() as $offer) {
|
||||
$version = $this->offers->purchasableVersion($offer);
|
||||
|
||||
if ($version !== null) {
|
||||
$options[] = $this->describe($offer, $version);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeilen für Shop-Suche und Kacheln: je Komposition die günstigste Option.
|
||||
*
|
||||
* @return array<int, array{from_cents: int, count: int}>
|
||||
*/
|
||||
public function summaries(): array
|
||||
{
|
||||
$summary = [];
|
||||
|
||||
foreach (Offer::query()->whereNotNull('composition_id')->orderBy('id')->get() as $offer) {
|
||||
$version = $this->offers->purchasableVersion($offer);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$current = $summary[$offer->composition_id] ?? ['from_cents' => PHP_INT_MAX, 'count' => 0];
|
||||
$summary[$offer->composition_id] = [
|
||||
'from_cents' => min($current['from_cents'], (int) $version->price_cents),
|
||||
'count' => $current['count'] + 1,
|
||||
];
|
||||
}
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function describe(Offer $offer, OfferVersion $version): array
|
||||
{
|
||||
$version->loadMissing('resolvedScopes.article', 'resolvedScopes.rights');
|
||||
$scope = [];
|
||||
|
||||
foreach ($version->resolvedScopes as $item) {
|
||||
$faehigkeiten = CatalogLabels::faehigkeiten($item->rights?->capabilities);
|
||||
$scope[] = [
|
||||
'article' => $this->articleTitle($item->article),
|
||||
'purpose' => CatalogLabels::zweck($item->rights?->purpose),
|
||||
'rights' => $faehigkeiten,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'offer' => $offer,
|
||||
'version' => $version,
|
||||
'name' => $offer->optionName(),
|
||||
'price_cents' => (int) $version->price_cents,
|
||||
'price' => Money::format((int) $version->price_cents),
|
||||
'for' => $version->holder_kind === 'organisation' ? 'Organisationen und Vereine' : 'Privatpersonen',
|
||||
'holder_kind' => $version->holder_kind,
|
||||
'term' => self::termLabel($version),
|
||||
'scope' => $scope,
|
||||
];
|
||||
}
|
||||
|
||||
public static function termLabel(OfferVersion $version): string
|
||||
{
|
||||
return match ($version->term_rule) {
|
||||
'dauerhaft' => 'Dauerhaft nutzbar',
|
||||
'befristet' => 'Befristet',
|
||||
'solange_angebot_aktiv' => 'Solange das Angebot aktiv ist',
|
||||
'periodisch' => 'Laufend, periodisch',
|
||||
default => (string) $version->term_rule,
|
||||
};
|
||||
}
|
||||
|
||||
public function articleTitle(?LicenseArticle $article): string
|
||||
{
|
||||
if ($article === null) {
|
||||
return '–';
|
||||
}
|
||||
|
||||
return $this->articleName($article) ?: (string) $article->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name wie in der Redaktion: eigener Name, sonst der Name des Inhalts (Anzeigename, Arbeitstitel oder
|
||||
* Bezeichnung), sonst der eigene Arbeitstitel; leer, wenn nichts davon vorhanden ist.
|
||||
*/
|
||||
public function articleName(LicenseArticle $article): string
|
||||
{
|
||||
$profile = app(EditorialProfileReader::class)->read($article, 'detail');
|
||||
$source = $profile->source;
|
||||
$candidates = [
|
||||
$profile->value('display_title'),
|
||||
$article->working_title,
|
||||
$source?->getAttribute('working_title'),
|
||||
$source?->getAttribute('designation'),
|
||||
];
|
||||
|
||||
foreach ($candidates as $candidate) {
|
||||
if (filled($candidate)) {
|
||||
return trim((string) $candidate);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
/**
|
||||
* Etappe 1 verwendet ausschließlich Testzahlung und erteilt keine Produktivfreigabe. Der Shop (Warenkorb, Kasse,
|
||||
* Kopflink) ist deshalb nur aktiv, wenn die Umgebung nicht Produktion ist und der Zahlungstreiber „test“ gilt.
|
||||
* Dieselbe Bedingung gilt für die Testzahlung der Bestellseite.
|
||||
*/
|
||||
final class Shop
|
||||
{
|
||||
public static function enabled(): bool
|
||||
{
|
||||
return ! app()->isProduction() && config('services.payment.driver') === 'test';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
|
||||
/**
|
||||
* Preis oder bindende Bedingungen haben sich nach Anzeige der Bestellübersicht geändert. Es entsteht keine
|
||||
* Bestellung; der Käufer sieht zuerst die aktualisierte Übersicht (FACH-59).
|
||||
*/
|
||||
class StaleOverview extends DomainRuleException {}
|
||||
@@ -19,6 +19,7 @@ class Acquisition extends Model
|
||||
'reference_type',
|
||||
'reference_id',
|
||||
'conditions',
|
||||
'acting_user_id',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
|
||||
@@ -47,7 +47,7 @@ public function __invoke(
|
||||
$candidates = Grant::query()
|
||||
->where('license_article_id', $article->id)
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||
->usableBy($user)
|
||||
->get()
|
||||
->filter(function (Grant $grant) use ($now): bool {
|
||||
if ($grant->valid_from !== null && $grant->valid_from->greaterThan($now)) {
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Identity\Membership;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
@@ -32,6 +35,32 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechtigungen, die ein Konto nutzen darf (zentrale Regel für Entscheidung, Bibliothek und Vorschaubilder):
|
||||
* - persönliche Erwerbe: Inhaber ist die Person des Kontos;
|
||||
* - Erwerbe einer Organisation: nur das auslösende Konto und nur, solange seine Mitgliedschaft mit
|
||||
* Bestellberechtigung besteht (Etappe 1, Domänenmodell 04; Sitzpools folgen mit A4).
|
||||
*
|
||||
* @param Builder<Grant> $query
|
||||
* @return Builder<Grant>
|
||||
*/
|
||||
public function scopeUsableBy(Builder $query, User $user): Builder
|
||||
{
|
||||
return $query->whereHas('acquisition', function (Builder $acquisition) use ($user): void {
|
||||
$acquisition->where(function (Builder $either) use ($user): void {
|
||||
$either->where('party_id', $user->party_id)
|
||||
->orWhere(function (Builder $organisation) use ($user): void {
|
||||
$organisation->where('acting_user_id', $user->id)
|
||||
->whereIn('party_id', Membership::query()
|
||||
->active()
|
||||
->where('user_id', $user->id)
|
||||
->where('may_order', true)
|
||||
->select('party_id'));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function acquisition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Acquisition::class);
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Commerce\OrderLine;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -69,6 +71,56 @@ public function grantManually(User $user, Offer $offer, User $actor, string $rea
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Freischaltung einer bezahlten Bestellposition aus deren festgehaltenem Umfang (Umfangskopie und Bedingungen der
|
||||
* Position, nicht aus der Angebotsfassung). Inhaber ist der Lizenzinhaber der Position, das auslösende Konto wird
|
||||
* am Erwerb festgehalten. Wiederholsicher: je Bestellposition genau ein Erwerb.
|
||||
*/
|
||||
public function issueFromOrderLine(OrderLine $line, Party $holder, User $actor): Acquisition
|
||||
{
|
||||
return DB::transaction(function () use ($line, $holder, $actor): Acquisition {
|
||||
$existing = Acquisition::query()->where([
|
||||
'party_id' => $holder->id,
|
||||
'type' => AcquisitionType::Bestellposition,
|
||||
'reference_type' => 'order_line',
|
||||
'reference_id' => $line->id,
|
||||
])->first();
|
||||
|
||||
if ($existing !== null) {
|
||||
return $existing->load('grants');
|
||||
}
|
||||
|
||||
$acquisition = Acquisition::query()->create([
|
||||
'party_id' => $holder->id,
|
||||
'type' => AcquisitionType::Bestellposition,
|
||||
'reference_type' => 'order_line',
|
||||
'reference_id' => $line->id,
|
||||
'acting_user_id' => $actor->id,
|
||||
'conditions' => [
|
||||
'term_rule' => $line->term_rule,
|
||||
'update_promise' => $line->update_promise,
|
||||
'holder_kind' => $line->holder_kind,
|
||||
'offer_version_id' => $line->offer_version_id,
|
||||
],
|
||||
]);
|
||||
|
||||
$line->loadMissing('scopeItems.article');
|
||||
|
||||
foreach ($line->scopeItems as $item) {
|
||||
$acquisition->grants()->create([
|
||||
'license_article_id' => $item->license_article_id,
|
||||
'rights_profile_version_id' => $item->rights_profile_version_id,
|
||||
'rights_snapshot' => $item->rights_snapshot,
|
||||
'release_at_grant_id' => $item->article?->current_release_id,
|
||||
'status' => GrantStatus::Aktiv,
|
||||
'valid_from' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $acquisition->load('grants');
|
||||
});
|
||||
}
|
||||
|
||||
public function issue(
|
||||
User $user,
|
||||
OfferVersion $version,
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Identity;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Mitgliedschaft eines Kontos in einer Organisation (Domänenmodell 04, MEMBERSHIP). Etappe 1 nutzt sie für die
|
||||
* Bestellberechtigung: Ein Konto bestellt nur für eine Organisation, bei der eine aktive Mitgliedschaft mit
|
||||
* `may_order` besteht. Sitzpools und Selbstverwaltung folgen mit A4.
|
||||
*/
|
||||
class Membership extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'party_id',
|
||||
'role',
|
||||
'may_order',
|
||||
'valid_from',
|
||||
'valid_until',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'may_order' => 'boolean',
|
||||
'valid_from' => 'date',
|
||||
'valid_until' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function organisation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Party::class, 'party_id');
|
||||
}
|
||||
|
||||
/** Mitgliedschaften, die heute gelten. */
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query
|
||||
->where(fn (Builder $inner) => $inner->whereNull('valid_from')->orWhereDate('valid_from', '<=', now()))
|
||||
->where(fn (Builder $inner) => $inner->whereNull('valid_until')->orWhereDate('valid_until', '>=', now()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Übernimmt das Vorschaubild eines Programms oder Moduls als gewöhnliches Bild-Medium im Medienmanager
|
||||
* (Programm- und Modulkarte), nach demselben Prinzip wie FilmStill.
|
||||
*
|
||||
* - Ausdrückliche Handlung der Redaktion. Das Vorschaubild ist ein geschütztes Bibliotheksbild; erst die Übernahme
|
||||
* legt ein Medium an, das für die Website freigegeben werden kann (WebsiteIntake, Warteschlange).
|
||||
* - Die Datei wird einmal kopiert. Dieselbe Vorschaudatei ergibt dasselbe Medium (composition_still_sources).
|
||||
* - Es entsteht keine Fassung, keine Berechtigung, kein Lizenzartikel.
|
||||
*/
|
||||
class CompositionStill
|
||||
{
|
||||
/** Wahr, wenn der letzte Aufruf ein schon vorhandenes Bild geliefert hat. */
|
||||
public bool $reused = false;
|
||||
|
||||
public function __construct(private readonly WebsiteIntake $intake) {}
|
||||
|
||||
public function refusal(Composition $composition): ?string
|
||||
{
|
||||
if ($composition->archived_at !== null) {
|
||||
return 'Das Programm oder Modul ist archiviert.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function hasThumbnail(Composition $composition): bool
|
||||
{
|
||||
$path = $composition->thumbnail_path;
|
||||
|
||||
return is_string($path) && str_starts_with($path, 'vorschau/') && ! str_contains($path, '..')
|
||||
&& Storage::disk('media_derived')->exists($path);
|
||||
}
|
||||
|
||||
public function fromThumbnail(Composition $composition, ?User $actor = null): ContentElement
|
||||
{
|
||||
$this->reused = false;
|
||||
$refusal = $this->refusal($composition);
|
||||
|
||||
if ($refusal !== null) {
|
||||
throw new DomainRuleException($refusal);
|
||||
}
|
||||
|
||||
if (! $this->hasThumbnail($composition)) {
|
||||
throw new DomainRuleException('Dieses Programm oder Modul hat noch kein Vorschaubild. Setzen Sie es im Redaktionsmanager.');
|
||||
}
|
||||
|
||||
$bytes = Storage::disk('media_derived')->get((string) $composition->thumbnail_path);
|
||||
|
||||
if (! is_string($bytes) || $bytes === '') {
|
||||
throw new DomainRuleException('Das Vorschaubild ließ sich nicht lesen.');
|
||||
}
|
||||
|
||||
$key = 'file:'.hash('sha256', $bytes);
|
||||
$existing = $this->existing($composition, $key);
|
||||
|
||||
if ($existing instanceof ContentElement) {
|
||||
$this->reused = true;
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$title = (string) ($composition->display_title ?: $composition->designation);
|
||||
$path = 'cms/titelbild-'.$composition->id.'-'.Str::lower(Str::random(8)).'.jpg';
|
||||
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||
|
||||
$still = $this->intake->acceptImage($path, 'Titelbild: '.$title, null, 'Titelbild zu „'.$title.'“', $actor);
|
||||
|
||||
try {
|
||||
CompositionStillSource::query()->updateOrCreate(
|
||||
['composition_id' => $composition->id, 'source_key' => $key],
|
||||
['still_element_id' => $still->id, 'actor_id' => $actor?->id],
|
||||
);
|
||||
} catch (QueryException) {
|
||||
return $this->existing($composition, $key) ?? $still;
|
||||
}
|
||||
|
||||
return $still;
|
||||
}
|
||||
|
||||
private function existing(Composition $composition, string $key): ?ContentElement
|
||||
{
|
||||
$source = CompositionStillSource::query()->with('still')->where('composition_id', $composition->id)->where('source_key', $key)->first();
|
||||
$still = $source?->still;
|
||||
|
||||
// Ein archiviertes oder bei der Verarbeitung gescheitertes Bild wird nicht wiederverwendet.
|
||||
return $still instanceof ContentElement && $still->archived_at === null && ! filled($still->thumbnail_error) ? $still : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Herkunft eines Bild-Mediums aus dem Vorschaubild eines Programms oder Moduls (source_key file:{SHA-256}).
|
||||
*/
|
||||
class CompositionStillSource extends Model
|
||||
{
|
||||
protected $fillable = ['composition_id', 'still_element_id', 'source_key', 'actor_id'];
|
||||
|
||||
public function composition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Composition::class);
|
||||
}
|
||||
|
||||
public function still(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElement::class, 'still_element_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Legt ein Bild aus einem Film als gewöhnliches Bild-Medium im Medienmanager ab (Medien- und Materialkarte).
|
||||
*
|
||||
* - Zwei Wege: das Vorschaubild des Films übernehmen oder eine Stelle (Sekunde) wählen. Beides ist eine
|
||||
* ausdrückliche Handlung der Redaktion; erst dadurch entsteht ein Bild, das für die Website freigegeben werden kann.
|
||||
* - Das Bild wird einmal gezogen und gespeichert (WebsiteIntake legt es an, die Warteschlange leitet es ab und gibt
|
||||
* es frei). Seitenaufrufe lesen nur die gespeicherte Datei und starten nie ffmpeg.
|
||||
* - Dieselbe Stelle (oder dieselbe Vorschaudatei) ergibt dasselbe Medium (film_still_sources).
|
||||
* - Es wird nie der Film selbst, nur ein Einzelbild bis 1600 px Breite abgelegt. Traineranleitungen und
|
||||
* archivierte oder gesperrte Filme sind ausgeschlossen. Eine Rechte- oder Lizenzentscheidung entsteht nicht.
|
||||
*/
|
||||
class FilmStill
|
||||
{
|
||||
/** Breite eines übernommenen Standbilds; die kleine Filmstufe (640 px) wäre auf der Website sichtbar unscharf. */
|
||||
public const WIDTH = 1600;
|
||||
|
||||
/** Wahr, wenn der letzte Aufruf ein schon vorhandenes Bild geliefert hat (keine neue Extraktion). */
|
||||
public bool $reused = false;
|
||||
|
||||
public function __construct(
|
||||
private readonly ThumbnailDeriver $deriver,
|
||||
private readonly WebsiteIntake $intake,
|
||||
) {}
|
||||
|
||||
/** Grund, warum aus diesem Medium kein Standbild übernommen wird, sonst null. */
|
||||
public function refusal(ContentElement $film): ?string
|
||||
{
|
||||
if ($film->output_class !== 'film') {
|
||||
return 'Nur aus einem Film lässt sich ein Bild übernehmen.';
|
||||
}
|
||||
|
||||
if ($film->archived_at !== null) {
|
||||
return 'Der Film ist archiviert.';
|
||||
}
|
||||
|
||||
$slug = $film->editorialContentKind?->slug;
|
||||
|
||||
if (in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true)) {
|
||||
return 'Aus Traineranleitungen werden keine Bilder für die Website übernommen.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Die bereitgestellte Fassung, aus der Stellen gezogen werden (die höchste). */
|
||||
public function version(ContentElement $film): ?ContentElementVersion
|
||||
{
|
||||
return $film->versions()
|
||||
->where('status', ContentVersionStatus::Bereit->value)
|
||||
->orderByDesc('number')
|
||||
->first();
|
||||
}
|
||||
|
||||
/** Sekunde der Stelle, aus der das aktuelle Vorschaubild des Films stammt, sonst null. */
|
||||
public function thumbnailSecond(ContentElement $film): ?string
|
||||
{
|
||||
$source = $film->thumbnail_source;
|
||||
|
||||
return is_string($source) && preg_match('/^frame:\d+@([\d.]+)$/', $source, $match) === 1 ? $match[1] : null;
|
||||
}
|
||||
|
||||
public function fromSecond(ContentElement $film, float $seconds, ?User $actor = null): ContentElement
|
||||
{
|
||||
$this->reused = false;
|
||||
$this->guard($film);
|
||||
|
||||
if ($seconds < 0 || $seconds > 7200) {
|
||||
throw new DomainRuleException('Die Zeitposition liegt außerhalb des Films.');
|
||||
}
|
||||
|
||||
$version = $this->version($film);
|
||||
|
||||
if (! $version instanceof ContentElementVersion) {
|
||||
throw new DomainRuleException('Der Film hat noch keine bereitgestellte Fassung.');
|
||||
}
|
||||
|
||||
return $this->fromFrame($film, $version, $seconds, $actor);
|
||||
}
|
||||
|
||||
public function fromThumbnail(ContentElement $film, ?User $actor = null): ContentElement
|
||||
{
|
||||
$this->reused = false;
|
||||
$this->guard($film);
|
||||
|
||||
// Stammt das Vorschaubild aus einer Filmstelle, wird dieselbe Stelle in voller Auflösung gezogen.
|
||||
$second = $this->thumbnailSecond($film);
|
||||
|
||||
if ($second !== null && preg_match('/^frame:(\d+)@/', (string) $film->thumbnail_source, $match) === 1) {
|
||||
$version = ContentElementVersion::query()->find((int) $match[1]);
|
||||
|
||||
if ($version instanceof ContentElementVersion
|
||||
&& (int) $version->content_element_id === (int) $film->id
|
||||
&& $version->status !== ContentVersionStatus::Gesperrt) {
|
||||
try {
|
||||
return $this->fromFrame($film, $version, (float) $second, $actor);
|
||||
} catch (DomainRuleException) {
|
||||
// Die Stelle lässt sich nicht mehr ziehen: das gespeicherte Vorschaubild selbst übernehmen.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$path = $film->thumbnail_path;
|
||||
|
||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..') || ! Storage::disk('media_derived')->exists($path)) {
|
||||
throw new DomainRuleException('Dieser Film hat noch kein Vorschaubild. Setzen Sie es im Medienmanager oder wählen Sie eine Stelle.');
|
||||
}
|
||||
|
||||
$bytes = Storage::disk('media_derived')->get($path);
|
||||
|
||||
if (! is_string($bytes) || $bytes === '') {
|
||||
throw new DomainRuleException('Das Vorschaubild ließ sich nicht lesen.');
|
||||
}
|
||||
|
||||
$key = 'file:'.hash('sha256', $bytes);
|
||||
$existing = $this->existing($film, $key);
|
||||
|
||||
if ($existing instanceof ContentElement) {
|
||||
$this->reused = true;
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
return $this->store($film, $key, $bytes, 'Vorschaubild', $actor);
|
||||
}
|
||||
|
||||
private function fromFrame(ContentElement $film, ContentElementVersion $version, float $seconds, ?User $actor): ContentElement
|
||||
{
|
||||
$second = $this->secondText($seconds);
|
||||
$key = 'frame:'.$version->id.'@'.$second;
|
||||
$existing = $this->existing($film, $key);
|
||||
|
||||
if ($existing instanceof ContentElement) {
|
||||
$this->reused = true;
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$bytes = $this->deriver->frameJpeg($version, (float) $second, self::WIDTH, original: true);
|
||||
|
||||
if (! is_string($bytes)) {
|
||||
throw new DomainRuleException('Aus dieser Filmstelle ließ sich kein Bild erzeugen.');
|
||||
}
|
||||
|
||||
return $this->store($film, $key, $bytes, 'Fassung '.$version->number.', '.str_replace('.', ',', $second).' s', $actor);
|
||||
}
|
||||
|
||||
private function guard(ContentElement $film): void
|
||||
{
|
||||
$refusal = $this->refusal($film);
|
||||
|
||||
if ($refusal !== null) {
|
||||
throw new DomainRuleException($refusal);
|
||||
}
|
||||
}
|
||||
|
||||
private function existing(ContentElement $film, string $key): ?ContentElement
|
||||
{
|
||||
$source = FilmStillSource::query()->with('still')->where('film_element_id', $film->id)->where('source_key', $key)->first();
|
||||
$still = $source?->still;
|
||||
|
||||
// Ein archiviertes oder an der Verarbeitung gescheitertes Bild wird nicht wiederverwendet; die Stelle kann neu
|
||||
// übernommen werden (store() ordnet dann das neue Bild zu).
|
||||
return $still instanceof ContentElement && $still->archived_at === null && ! filled($still->thumbnail_error) ? $still : null;
|
||||
}
|
||||
|
||||
private function store(ContentElement $film, string $key, string $bytes, string $label, ?User $actor): ContentElement
|
||||
{
|
||||
$title = (string) ($film->display_title ?: $film->working_title);
|
||||
$path = 'cms/standbild-'.$film->id.'-'.Str::lower(Str::random(8)).'.jpg';
|
||||
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||
|
||||
$still = $this->intake->acceptImage(
|
||||
$path,
|
||||
'Standbild: '.$title.' ('.$label.')',
|
||||
filled($film->website_credit) ? (string) $film->website_credit : null,
|
||||
'Szene aus dem Film „'.$title.'“',
|
||||
$actor,
|
||||
);
|
||||
|
||||
try {
|
||||
FilmStillSource::query()->updateOrCreate(
|
||||
['film_element_id' => $film->id, 'source_key' => $key],
|
||||
['still_element_id' => $still->id, 'actor_id' => $actor?->id],
|
||||
);
|
||||
} catch (QueryException) {
|
||||
// Gleichzeitige Übernahme derselben Stelle: das zuerst angelegte Bild gilt.
|
||||
return $this->existing($film, $key) ?? $still;
|
||||
}
|
||||
|
||||
return $still;
|
||||
}
|
||||
|
||||
private function secondText(float $seconds): string
|
||||
{
|
||||
$text = number_format(max(0, min(7200, $seconds)), 3, '.', '');
|
||||
|
||||
return rtrim(rtrim($text, '0'), '.') ?: '0';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Herkunft eines Standbilds: aus welchem Film und welcher Stelle (frame:{Fassung}@{Sekunde}) oder aus welcher Datei
|
||||
* (file:{SHA-256}) das Bild-Medium stammt.
|
||||
*/
|
||||
class FilmStillSource extends Model
|
||||
{
|
||||
protected $fillable = ['film_element_id', 'still_element_id', 'source_key', 'actor_id'];
|
||||
|
||||
public function film(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElement::class, 'film_element_id');
|
||||
}
|
||||
|
||||
public function still(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElement::class, 'still_element_id');
|
||||
}
|
||||
}
|
||||
@@ -138,8 +138,20 @@ public function forCompositionFrame(Composition $composition, ContentElementVers
|
||||
$this->rememberChoice($composition, 'frame:'.$version->id.'@'.$this->secondText($seconds));
|
||||
}
|
||||
|
||||
public function frameInput(ContentElementVersion $version): ?string
|
||||
/**
|
||||
* Datei, aus der ein Bild gezogen wird. Vorgabe: die kleine Filmstufe (schnell, für die Vorschau). Mit $original
|
||||
* zuerst die Mediendatei selbst, damit ein übernommenes Standbild nicht aus der kleinen Stufe hochgerechnet wird.
|
||||
*/
|
||||
public function frameInput(ContentElementVersion $version, bool $original = false): ?string
|
||||
{
|
||||
if ($original) {
|
||||
$master = is_array($version->metadata) ? ($version->metadata['file'] ?? null) : null;
|
||||
|
||||
if ($this->readableDerived($master, 'inhalte/')) {
|
||||
return $master;
|
||||
}
|
||||
}
|
||||
|
||||
$proxy = MediaRendition::query()
|
||||
->where('content_element_version_id', $version->id)
|
||||
->where('role', 'variant')
|
||||
@@ -155,13 +167,25 @@ public function frameInput(ContentElementVersion $version): ?string
|
||||
return $this->readableDerived($file, 'inhalte/') ? $file : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Einzelbild einer Filmstelle als JPEG, 640 px breit aus der kleinen Stufe (Vorschau im Editor und Vorschaubild).
|
||||
*/
|
||||
public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?string
|
||||
{
|
||||
return $this->frameJpeg($version, $seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Einzelbild einer Filmstelle als JPEG. Ein übernommenes Standbild (FilmStill) wird mit $width und $original aus der
|
||||
* Mediendatei gezogen statt aus der kleinen Stufe und dabei nie über die Breite der Quelle hinaus vergrößert.
|
||||
*/
|
||||
public function frameJpeg(ContentElementVersion $version, float $seconds, int $width = 640, bool $original = false): ?string
|
||||
{
|
||||
if ($seconds < 0 || $seconds > 7200) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$file = $this->frameInput($version);
|
||||
$file = $this->frameInput($version, $original);
|
||||
|
||||
if ($file === null) {
|
||||
return null;
|
||||
@@ -186,7 +210,7 @@ public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?
|
||||
'-frames:v',
|
||||
'1',
|
||||
'-vf',
|
||||
'scale=640:-2',
|
||||
$width === 640 ? 'scale=640:-2' : 'scale=min('.max(160, min(2400, $width)).'\,iw):-2',
|
||||
'-f',
|
||||
'image2pipe',
|
||||
'-vcodec',
|
||||
|
||||
@@ -37,6 +37,16 @@ public static function effectiveFor(mixed $path): ?self
|
||||
return $alias instanceof self && $alias->everReleased() ? $alias : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Früherer Pfad, dessen übernommenes Medium inzwischen gelöscht wurde. Die Datei unter cms/ bleibt liegen, wird aber
|
||||
* weder ausgeliefert noch als Bild gezeigt: Das Löschen des Mediums gilt auch für die frühere Adresse.
|
||||
*/
|
||||
public static function isRetired(mixed $path): bool
|
||||
{
|
||||
return is_string($path) && $path !== ''
|
||||
&& self::query()->where('legacy_path', $path)->whereNull('content_element_id')->exists();
|
||||
}
|
||||
|
||||
public function everReleased(): bool
|
||||
{
|
||||
$element = $this->element;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Filament\Resources\Bundles\BundleResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
@@ -90,7 +91,8 @@ public function publishAction(): Action
|
||||
->modalSubmitActionLabel(fn (): string => 'Fassung '.$this->nextNumber().' veröffentlichen')
|
||||
->fillForm(fn (): array => $this->formFromPublished())
|
||||
->schema([
|
||||
CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => CatalogOptions::articles()),
|
||||
CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => app(PublicationReadiness::class)->articleOptions())
|
||||
->helperText('Artikel ohne Stand lassen sich aufnehmen, aber erst verkaufen, wenn sie einen Inhalt haben.'),
|
||||
CheckboxList::make('bundles')->label('Enthaltene Pakete')
|
||||
->options(function (): array {
|
||||
$options = CatalogOptions::bundles();
|
||||
@@ -115,7 +117,12 @@ public function publishAction(): Action
|
||||
|
||||
$version = app(BundleService::class)->publish($bundle, $items);
|
||||
|
||||
return 'Fassung '.$version->number.' ist veröffentlicht.';
|
||||
$bundle->unsetRelations();
|
||||
$readiness = app(PublicationReadiness::class)->forBundle($bundle->refresh());
|
||||
|
||||
return 'Fassung '.$version->number.' ist veröffentlicht.'.($readiness['naechster'] !== null
|
||||
? ' Nächster Schritt: '.$readiness['naechster']['titel'].'.'
|
||||
: '');
|
||||
}, 'Die Paketfassung ist veröffentlicht.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
@@ -164,6 +171,7 @@ private function paketDaten(): array
|
||||
'art' => 'primary',
|
||||
]],
|
||||
],
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forBundle($bundle),
|
||||
'haupt' => [
|
||||
[
|
||||
'titel' => 'Bestandteile',
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\AssignsPillars;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\ManagesEditorialSurface;
|
||||
use App\Filament\Support\MediumForm;
|
||||
@@ -43,6 +44,7 @@
|
||||
|
||||
abstract class EditComposition extends EditRecord
|
||||
{
|
||||
use AssignsPillars;
|
||||
use ManagesEditorialSurface;
|
||||
use WithFileUploads;
|
||||
|
||||
@@ -398,11 +400,15 @@ public function redaktionTexteHinweis(): string
|
||||
*/
|
||||
public function einordnungGruppen(): array
|
||||
{
|
||||
return array_map(fn (array $group): array => [
|
||||
$groups = array_map(fn (array $group): array => [
|
||||
'legend' => $group['label'],
|
||||
'model' => 'dimensionIds',
|
||||
'values' => $group['values'],
|
||||
], $this->dimensionGroups());
|
||||
|
||||
$pillars = $this->pillarGroup();
|
||||
|
||||
return $pillars === null ? $groups : [$pillars, ...$groups];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -466,7 +472,7 @@ public function einordnungUnsaved(): bool
|
||||
sort($stored);
|
||||
sort($current);
|
||||
|
||||
return $stored !== $current;
|
||||
return $stored !== $current || $this->pillarsUnsaved($record);
|
||||
}
|
||||
|
||||
public function openText(): void
|
||||
@@ -1654,6 +1660,7 @@ protected function fillRedaktion(): void
|
||||
->pluck('editorial_dimension_value_id')
|
||||
->map(fn (mixed $id): string => (string) (int) $id)
|
||||
->all();
|
||||
$this->loadPillarIds($composition);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1913,6 +1920,7 @@ protected function persistRedaktion(): bool
|
||||
'description' => $this->description,
|
||||
], $this->actor());
|
||||
$this->syncDimensions($record, array_map(intval(...), $this->dimensionIds));
|
||||
$this->persistPillarIds($record);
|
||||
$record->refresh();
|
||||
$this->getRecord()->setRawAttributes($record->getAttributes());
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\ContentElements\Pages;
|
||||
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\PillarFilterCompat;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\Bestand;
|
||||
use App\Filament\Support\MediaLibrary;
|
||||
@@ -170,6 +171,11 @@ public function resetFilters(): void
|
||||
*/
|
||||
public function bestand(): array
|
||||
{
|
||||
// Alte Adressen mit einem Säulenwert der Einordnung gelten für die zentrale Säule.
|
||||
if (ctype_digit($this->einordnung) && $this->saeule === '' && is_int($pillar = PillarFilterCompat::pillarOfLegacyValue((int) $this->einordnung))) {
|
||||
[$this->saeule, $this->einordnung] = [(string) $pillar, ''];
|
||||
}
|
||||
|
||||
$optionen = fn (array $liste, string $wert, string $label): array => collect($liste)
|
||||
->mapWithKeys(fn (array $eintrag): array => [(string) $eintrag[$wert] => $eintrag[$label]])
|
||||
->all();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ListLicenseArticles;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -57,6 +58,7 @@ public static function infolist(Schema $schema): Schema
|
||||
->viewData(fn (LicenseArticle $record): array => [
|
||||
'stand' => app(CatalogReading::class)->articleStand($record),
|
||||
'kontext' => app(CatalogReading::class)->articleContext($record),
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forArticle($record),
|
||||
])
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Support\AssignsPillars;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\ManagesEditorialSurface;
|
||||
@@ -30,6 +31,7 @@
|
||||
|
||||
class ViewLicenseArticle extends ViewRecord
|
||||
{
|
||||
use AssignsPillars;
|
||||
use ManagesEditorialSurface;
|
||||
use ReportsDomainRules;
|
||||
|
||||
@@ -115,6 +117,7 @@ protected function saveRedaktionTexte(): bool
|
||||
], auth()->user());
|
||||
|
||||
app(IdentityDimension::class)->replaceOffered($article, array_map(intval(...), $this->dimensionIds));
|
||||
$this->persistPillarIds($article);
|
||||
|
||||
$article->refresh();
|
||||
$this->fillLicenseEditorial();
|
||||
@@ -159,7 +162,7 @@ public function einordnungUnsaved(): bool
|
||||
sort($stored);
|
||||
sort($current);
|
||||
|
||||
return $stored !== $current;
|
||||
return $stored !== $current || $this->pillarsUnsaved($article);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,11 +273,15 @@ public function einordnungArt(): array
|
||||
*/
|
||||
public function einordnungGruppen(): array
|
||||
{
|
||||
return array_map(fn (array $group): array => [
|
||||
$groups = array_map(fn (array $group): array => [
|
||||
'legend' => $group['label'],
|
||||
'model' => 'dimensionIds',
|
||||
'values' => $group['values'],
|
||||
], $this->licenseDimensionGroups());
|
||||
|
||||
$pillars = $this->pillarGroup();
|
||||
|
||||
return $pillars === null ? $groups : [$pillars, ...$groups];
|
||||
}
|
||||
|
||||
private function sourceTitle(Model $source): string
|
||||
@@ -312,6 +319,7 @@ private function fillLicenseEditorial(): void
|
||||
->where('origin', 'direkt')
|
||||
->pluck('editorial_dimension_value_id')
|
||||
->all();
|
||||
$this->loadPillarIds($article);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
@@ -322,12 +330,28 @@ protected function getHeaderActions(): array
|
||||
public function releaseAction(): Action
|
||||
{
|
||||
return Action::make('release')
|
||||
->label('Stand veröffentlichen')
|
||||
->label(fn (): string => $this->isFirstStand() ? 'Inhalt festlegen' : 'Neuen Stand veröffentlichen')
|
||||
->modalHeading(fn (): string => $this->isFirstStand() ? 'Inhalt festlegen: ersten Stand veröffentlichen' : 'Neuen Stand veröffentlichen')
|
||||
->modalDescription(fn (): string => $this->isFirstStand()
|
||||
? 'Der Stand legt fest, welche Inhalte dieser Lizenzartikel lizenziert: der gewählte Inhalt samt allem, was er enthält. Er ist danach unveränderlich. Pakete und Angebote können den Artikel danach verwenden; verkauft wird er erst über ein Angebot.'
|
||||
: 'Ein neuer Stand ersetzt den aktuellen für künftige Ausgaben. Bestehende Käufer erhalten ihn im Rahmen ihrer Lizenz; frühere Stände bleiben gespeichert.')
|
||||
->modalSubmitActionLabel('Stand veröffentlichen')
|
||||
->fillForm(fn (): array => $this->isFirstStand() ? ['classification' => 'Erster Stand dieses Lizenzartikels.'] : [])
|
||||
->schema([
|
||||
Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
Textarea::make('classification')->label('Einordnung')->required()
|
||||
->helperText('Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
||||
TextInput::make('change_note')->label('Änderungshinweis'),
|
||||
Select::make('root')->label('Freigegebener Inhalt')
|
||||
->options(fn (): array => CatalogOptions::assignmentTargets())
|
||||
->searchable()
|
||||
->required()
|
||||
->helperText(fn (): string => CatalogOptions::assignmentTargets() === []
|
||||
? 'Es gibt noch keinen freigegebenen Inhalt. Gib zuerst ein Medium, Modul oder Programm frei.'
|
||||
: 'Medien, Module und Programme mit freigegebener Fassung. Bei Modulen und Programmen gehört alles Enthaltene zum Stand.'),
|
||||
Textarea::make('classification')->label('Einordnung')
|
||||
->required(fn (): bool => ! $this->isFirstStand())
|
||||
->helperText(fn (): string => $this->isFirstStand()
|
||||
? 'Beim ersten Stand genügt der vorgegebene Text.'
|
||||
: 'Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
||||
TextInput::make('change_note')->label('Änderungshinweis')
|
||||
->visible(fn (): bool => ! $this->isFirstStand()),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
@@ -340,7 +364,7 @@ public function releaseAction(): Action
|
||||
$release = app(ArticleService::class)->publishRelease(
|
||||
$article,
|
||||
$root,
|
||||
$data['classification'],
|
||||
(string) ($data['classification'] ?? 'Erster Stand dieses Lizenzartikels.'),
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
$report = $release->impact_report ?? [];
|
||||
@@ -375,6 +399,11 @@ public function withdrawAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
private function isFirstStand(): bool
|
||||
{
|
||||
return ! $this->getRecord()->releases()->exists();
|
||||
}
|
||||
|
||||
private function refreshRecord(): void
|
||||
{
|
||||
$this->getRecord()->unsetRelations();
|
||||
|
||||
@@ -64,6 +64,7 @@ protected function catalogRows(): array
|
||||
if ($active !== null) {
|
||||
$chips[] = ['label' => 'Fassung '.$active->number.' aktiv', 'ton' => 'gut'];
|
||||
$chips[] = ['label' => CatalogLabels::vergabe($active), 'ton' => 'neutral'];
|
||||
$chips[] = ['label' => $active->holder_kind === 'organisation' ? 'Für Organisationen' : 'Für Privatpersonen', 'ton' => 'neutral'];
|
||||
$zustand[] = 'aktiv';
|
||||
$text = $active->lines->map(fn ($line): string => ($line->article !== null
|
||||
? 'Lizenzartikel '.$line->article->code
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Filament\Resources\Offers\Pages;
|
||||
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
@@ -11,9 +14,13 @@
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -25,6 +32,7 @@
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Angebot im gemeinsamen Rahmen. Anlegen und Ändern nutzen dieselbe Maske (FACH-20): „Fassung aktivieren“ legt die
|
||||
@@ -91,22 +99,34 @@ public function activateAction(): Action
|
||||
return Action::make('activate')
|
||||
->label(fn (): string => $this->activeVersion() !== null ? 'Geänderte Fassung aktivieren' : 'Fassung aktivieren')
|
||||
->modalHeading(fn (): string => $this->activeVersion() !== null
|
||||
? 'Angebot ändern: Fassung '.$this->nextNumber().' aktivieren'
|
||||
: 'Erste Fassung aktivieren')
|
||||
? 'Option „'.$this->getRecord()->optionName().'“ ändern: Fassung '.$this->nextNumber().' aktivieren'
|
||||
: 'Option „'.$this->getRecord()->optionName().'“: erste Fassung aktivieren')
|
||||
->modalDescription(fn (): string => ($active = $this->activeVersion()) !== null
|
||||
? 'Die Maske ist mit Fassung '.$active->number.' vorbelegt; Inhaberart, Laufzeitregel und Steuerklasse werden übernommen. Beim Aktivieren wird Fassung '.$active->number.' beendet und bleibt unverändert gespeichert; neue Erwerbe nutzen Fassung '.$this->nextNumber().'. Bereits begründete Berechtigungen ändern sich dadurch nicht.'
|
||||
: 'Positionen, Vergabe und Preis bilden die erste Fassung. Nach dem Aktivieren ist sie unveränderlich; Änderungen ergeben eine weitere Fassung.')
|
||||
? 'Betroffen ist nur die Option „'.$this->getRecord()->optionName().'“'.$this->productPageSuffix().'. Die Maske ist mit Fassung '.$active->number.' vorbelegt. Erst „Fassung '.$this->nextNumber().' aktivieren“ schaltet die Änderung öffentlich (auch Bezeichnung und Produktseite, sie erzeugen ebenfalls eine neue Fassung und zeigen offenen Warenkörben „Bedingungen aktualisiert“): Fassung '.$active->number.' wird beendet und bleibt gespeichert, neue Käufe nutzen Fassung '.$this->nextNumber().'. Bereits begründete Berechtigungen und Bestellungen ändern sich nicht. Andere Optionen derselben Produktseite bleiben unverändert kaufbar. „Abbrechen“ verwirft die Eingaben.'
|
||||
: 'Positionen, Vergabe, Eignung und Preis bilden die erste Fassung dieser Option. Erst das Aktivieren macht sie öffentlich; danach ist sie unveränderlich, Änderungen ergeben eine weitere Fassung.')
|
||||
->modalSubmitActionLabel(fn (): string => 'Fassung '.$this->nextNumber().' aktivieren')
|
||||
->modalWidth('4xl')
|
||||
->fillForm(fn (): array => $this->formFromActive())
|
||||
->schema([
|
||||
TextInput::make('option_label')->label('Bezeichnung der Option')
|
||||
->helperText('So heißt die Option auf der Produktseite, zum Beispiel „Einzellizenz für Privatpersonen“. Sie ist keine bindende Bedingung, wird aber wie die übrigen Angaben erst mit „Fassung aktivieren“ übernommen.')
|
||||
->maxLength(120),
|
||||
Select::make('composition_id')->label('Produktseite')
|
||||
->options(fn (): array => $this->productPages())
|
||||
->searchable()
|
||||
->helperText('Optionen derselben Produktseite sind Alternativen; im Warenkorb liegt nur eine davon. Die Beschreibung der Seite wird zentral an der Komposition gepflegt. Die Zuordnung wird mit „Fassung aktivieren“ übernommen.'),
|
||||
Select::make('holder_kind')->label('Geeignet für')->options([
|
||||
'person' => 'Privatpersonen',
|
||||
'organisation' => 'Organisationen und Vereine',
|
||||
])->required()
|
||||
->helperText('Wähle die Eignung passend zu den Rechten: Organisationslizenzen brauchen institutionelle Rechte. Das System erzwingt diese Kopplung nicht.'),
|
||||
Select::make('grant_kind')->label('Vergabe')->options([
|
||||
'kauf' => 'Kauf',
|
||||
'auf_abruf' => 'Auf Abruf',
|
||||
'bei_registrierung' => 'Bei Registrierung',
|
||||
])->required(),
|
||||
TextInput::make('price_cents')->label('Preis in Cent')->numeric()
|
||||
->helperText('Nur bei einem Kauf. 500 bedeutet 5,00 €.'),
|
||||
TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')
|
||||
->helperText('Nur bei einem Kauf, zum Beispiel 49,00.'),
|
||||
Select::make('composition_version_id')->label('Programmfassung, die abgedeckt sein muss')
|
||||
->options(function (): array {
|
||||
return CompositionVersion::query()
|
||||
@@ -124,9 +144,12 @@ public function activateAction(): Action
|
||||
'article' => 'Lizenzartikel',
|
||||
'bundle' => 'Paketfassung',
|
||||
])->required()->live(),
|
||||
Select::make('article_id')->label('Artikel')->options(fn (): array => CatalogOptions::articles())
|
||||
Select::make('article_id')->label('Artikel')->options(fn (): array => app(PublicationReadiness::class)->articleOptions())
|
||||
->searchable()
|
||||
->helperText('Nur Artikel mit veröffentlichtem Stand lassen sich verkaufen. Artikel ohne Stand sind gekennzeichnet.')
|
||||
->visible(fn (Get $get): bool => $get('kind') === 'article'),
|
||||
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => CatalogOptions::bundleVersions())
|
||||
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => app(PublicationReadiness::class)->bundleVersionOptions())
|
||||
->searchable()
|
||||
->visible(fn (Get $get): bool => $get('kind') === 'bundle'),
|
||||
Select::make('rights_id')->label('Rechte')->options(fn (): array => CatalogOptions::rights())->required(),
|
||||
])->minItems(1)->addActionLabel('Position hinzufügen'),
|
||||
@@ -147,29 +170,117 @@ public function activateAction(): Action
|
||||
];
|
||||
}
|
||||
|
||||
// Bedingungen, die die Maske nicht zeigt, bleiben bei einer Änderung die der aktiven Fassung; ohne
|
||||
// aktive Fassung gilt wie bisher die Vorgabe (Personen, dauerhaft).
|
||||
// Voraussetzung: Jeder Artikel der Positionen hat einen veröffentlichten Stand, sonst erhielten Käufer nichts.
|
||||
$articleIds = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$target = $line['target'];
|
||||
array_push($articleIds, ...($target instanceof BundleVersion ? app(BundleService::class)->articleIds($target) : [$target->id]));
|
||||
}
|
||||
|
||||
$unusable = app(PublicationReadiness::class)->unusableArticles($articleIds);
|
||||
|
||||
if ($unusable !== []) {
|
||||
throw new DomainRuleException(app(PublicationReadiness::class)->unusableMessage($unusable, 'das Angebot aktivierst'));
|
||||
}
|
||||
|
||||
// Bedingungen, die die Maske nicht zeigt, bleiben bei einer Änderung die der aktiven Fassung.
|
||||
$active = $this->activeVersion();
|
||||
$kept = $active === null ? ['holder_kind' => 'person'] : [
|
||||
'holder_kind' => $active->holder_kind,
|
||||
$kept = $active === null ? [] : [
|
||||
'term_rule' => $active->term_rule,
|
||||
'tax_class' => $active->tax_class,
|
||||
'dynamic' => (bool) $active->dynamic,
|
||||
];
|
||||
$version = app(OfferService::class)->activate($offer, $lines, [
|
||||
...$kept,
|
||||
'grant_kind' => $data['grant_kind'],
|
||||
'price_cents' => $data['price_cents'] === null || $data['price_cents'] === '' ? null : (int) $data['price_cents'],
|
||||
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
||||
]);
|
||||
$price = Money::parse($data['price_euro'] ?? null);
|
||||
|
||||
return 'Fassung '.$version->number.' ist aktiv.';
|
||||
if ($data['grant_kind'] === 'kauf' && ($price === null || $price <= 0)) {
|
||||
throw new DomainRuleException('Ein Kauf braucht einen Preis über 0,00 €.');
|
||||
}
|
||||
|
||||
$service = app(OfferService::class);
|
||||
$version = DB::transaction(function () use ($service, $offer, $data, $lines, $kept, $price) {
|
||||
$service->assignProduct(
|
||||
$offer,
|
||||
filled($data['composition_id'] ?? null) ? (int) $data['composition_id'] : null,
|
||||
$data['option_label'] ?? null,
|
||||
);
|
||||
|
||||
return $service->activate($offer, $lines, [
|
||||
...$kept,
|
||||
'holder_kind' => $data['holder_kind'],
|
||||
'grant_kind' => $data['grant_kind'],
|
||||
'price_cents' => $price,
|
||||
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
||||
]);
|
||||
});
|
||||
|
||||
$offer->unsetRelations();
|
||||
$readiness = app(PublicationReadiness::class)->forOffer($offer->refresh());
|
||||
|
||||
return 'Fassung '.$version->number.' ist aktiv.'.($readiness['bereit']
|
||||
? ' Die Option ist öffentlich kaufbar und im Shop auffindbar.'
|
||||
: ' Noch nicht im Shop kaufbar. Nächster Schritt: '.$readiness['naechster']['titel'].'.');
|
||||
}, 'Die Angebotsfassung ist aktiv.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Option aus dem Verkauf nehmen: nur die aktive Fassung dieser Option wird beendet.
|
||||
*/
|
||||
public function endAction(): Action
|
||||
{
|
||||
return Action::make('end')
|
||||
->label('Aus dem Verkauf nehmen')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalHeading(fn (): string => 'Option „'.$this->getRecord()->optionName().'“ aus dem Verkauf nehmen?')
|
||||
->modalDescription(fn (): string => 'Betroffen ist nur die Option „'.$this->getRecord()->optionName().'“'.$this->productPageSuffix().'. Die aktive Fassung wird beendet und bleibt gespeichert. Die Option ist danach nicht mehr kaufbar; in vorhandenen Warenkörben bleibt sie mit Hinweis sichtbar und blockiert den Abschluss, bis der Käufer sie entfernt. Bestehende Berechtigungen und Bestellungen ändern sich nicht. Andere Optionen derselben Produktseite bleiben kaufbar.')
|
||||
->modalSubmitActionLabel('Aus dem Verkauf nehmen')
|
||||
->visible(fn (): bool => $this->activeVersion() !== null)
|
||||
->action(function (): void {
|
||||
$this->report(function (): string {
|
||||
$version = app(OfferService::class)->end($this->getRecord());
|
||||
|
||||
return 'Fassung '.$version->number.' ist beendet. Die Option ist nicht mehr kaufbar.';
|
||||
}, 'Die Option ist aus dem Verkauf genommen.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/** „ der Produktseite „Titel““ oder leer, wenn die Option noch keiner Produktseite zugeordnet ist. */
|
||||
private function productPageSuffix(): string
|
||||
{
|
||||
$page = $this->getRecord()->composition;
|
||||
|
||||
return $page === null ? '' : ' der Produktseite „'.($page->display_title ?: $page->designation).'“';
|
||||
}
|
||||
|
||||
/**
|
||||
* Produktseiten, die als Ziel wählbar sind: Kompositionen mit Bezeichnung und Art.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function productPages(): array
|
||||
{
|
||||
$catalog = app(PublicCatalogReader::class);
|
||||
|
||||
return Composition::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->orderBy('designation')
|
||||
->get()
|
||||
->sortBy(fn (Composition $composition): int => $catalog->shownVersion($composition) !== null ? 0 : 1)
|
||||
->mapWithKeys(fn (Composition $composition): array => [
|
||||
$composition->id => ($composition->display_title ?: $composition->designation)
|
||||
.' ('.($composition->editorialContentKind?->label ?? 'Zusammenstellung').')'
|
||||
.($catalog->shownVersion($composition) !== null ? ' · im Shop auffindbar' : ' · nicht öffentlich, im Shop nicht auffindbar'),
|
||||
])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorbelegung aus der aktiven Fassung; ohne aktive Fassung eine leere Position.
|
||||
*
|
||||
@@ -178,14 +289,19 @@ public function activateAction(): Action
|
||||
private function formFromActive(): array
|
||||
{
|
||||
$active = $this->activeVersion();
|
||||
/** @var Offer $offer */
|
||||
$offer = $this->getRecord();
|
||||
$option = ['option_label' => $offer->option_label, 'composition_id' => $offer->composition_id];
|
||||
|
||||
if ($active === null) {
|
||||
return ['grant_kind' => 'kauf', 'lines' => [['kind' => 'article']]];
|
||||
return [...$option, 'holder_kind' => 'person', 'grant_kind' => 'kauf', 'lines' => [['kind' => 'article']]];
|
||||
}
|
||||
|
||||
return [
|
||||
...$option,
|
||||
'holder_kind' => $active->holder_kind,
|
||||
'grant_kind' => $active->grant_kind,
|
||||
'price_cents' => $active->price_cents,
|
||||
'price_euro' => $active->price_cents === null ? null : number_format($active->price_cents / 100, 2, ',', ''),
|
||||
'lines' => $active->lines->sortBy('position')->map(fn ($line): array => [
|
||||
'kind' => $line->license_article_id !== null ? 'article' : 'bundle',
|
||||
'article_id' => $line->license_article_id,
|
||||
@@ -220,13 +336,22 @@ private function angebotDaten(): array
|
||||
'status' => $active !== null
|
||||
? ['text' => 'Fassung '.$active->number.' aktiv · '.$vergabe, 'ton' => 'gut']
|
||||
: ['text' => 'Noch keine aktive Fassung. Ein Angebot ohne aktive Fassung kann niemand erwerben.', 'ton' => 'offen'],
|
||||
'aktionen' => [[
|
||||
'label' => $active !== null ? 'Geänderte Fassung aktivieren' : 'Fassung aktivieren',
|
||||
'wire' => "mountAction('activate')",
|
||||
'art' => 'primary',
|
||||
]],
|
||||
'aktionen' => [
|
||||
[
|
||||
'label' => $active !== null ? 'Geänderte Fassung aktivieren' : 'Fassung aktivieren',
|
||||
'wire' => "mountAction('activate')",
|
||||
'art' => 'primary',
|
||||
],
|
||||
...($active !== null ? [[
|
||||
'label' => 'Aus dem Verkauf nehmen',
|
||||
'wire' => "mountAction('end')",
|
||||
'art' => 'line',
|
||||
]] : []),
|
||||
],
|
||||
],
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forOffer($offer),
|
||||
'haupt' => [
|
||||
...($active !== null ? [$this->optionAbschnitt($offer, $active)] : []),
|
||||
[
|
||||
'titel' => 'Positionen',
|
||||
'zusatz' => $active !== null ? 'Fassung '.$active->number : null,
|
||||
@@ -261,6 +386,37 @@ private function angebotDaten(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Option auf einen Blick: Preis in Euro, Eignung, Rechte, zugrunde liegender Inhalt, Status und Produktseite.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function optionAbschnitt(Offer $offer, OfferVersion $active): array
|
||||
{
|
||||
$option = app(ProductOptions::class)->describe($offer, $active);
|
||||
$inhalt = collect($option['scope'])->pluck('article')->unique()->implode(', ');
|
||||
$rechte = collect($option['scope'])
|
||||
->map(fn (array $item): string => $item['purpose'].($item['rights'] === [] ? '' : ': '.implode(', ', $item['rights'])))
|
||||
->unique()
|
||||
->implode('; ');
|
||||
$seite = $offer->composition;
|
||||
$kaufbar = app(OfferService::class)->purchasableVersion($offer) !== null;
|
||||
|
||||
return [
|
||||
'titel' => 'Die Option auf einen Blick',
|
||||
'zusatz' => 'Fassung '.$active->number,
|
||||
'hilfe' => 'So erscheint die Option auf der öffentlichen Produktseite und im Warenkorb. Die Angaben dieser Fassung sind unveränderlich.',
|
||||
'zeilen' => [
|
||||
['text' => 'Preis: '.$option['price'], 'neben' => $active->grant_kind === 'kauf' ? 'Kauf mit Testzahlung' : CatalogLabels::vergabe($active)],
|
||||
['text' => 'Geeignet für: '.$option['for'], 'neben' => $option['term']],
|
||||
['text' => 'Rechte: '.($rechte !== '' ? $rechte : 'keine'), 'neben' => null],
|
||||
['text' => 'Zugrunde liegender Inhalt: '.($inhalt !== '' ? $inhalt : '–'), 'neben' => null],
|
||||
['text' => 'Status: '.($kaufbar ? 'Öffentlich kaufbar' : 'Nicht als Kauf angeboten'), 'neben' => $kaufbar ? 'Aktive Fassung '.$active->number : null],
|
||||
['text' => 'Produktseite: '.($seite !== null ? ($seite->display_title ?: $seite->designation) : 'noch nicht zugeordnet'), 'neben' => $seite !== null ? 'Option „'.$offer->optionName().'“' : 'Mit „Geänderte Fassung aktivieren“ zuordnen.'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Aufgelöster Leistungsumfang in lesbaren Fähigkeiten (dieselben Bezeichnungen wie beim Rechteprofil).
|
||||
*
|
||||
|
||||
@@ -22,7 +22,7 @@ class ListPillars extends ListRecords
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Die fachlichen Säulen des Materials. Eine veröffentlichte Säule ist ein Themenbereich der Website. Ein Medium und eine Seite können mehreren Säulen zugeordnet sein.';
|
||||
return 'Die fachlichen Säulen des Materials. Eine veröffentlichte Säule ist ein Themenbereich der Website. Medien, Module, Programme, Lizenzartikel und Seiten können mehreren Säulen zugeordnet sein. Hier ist die einzige Pflegestelle der Säulen.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
@@ -50,11 +50,28 @@ protected function getHeaderActions(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Zuordnungen aller Objektarten; ohne Zuordnung wie bisher „0 Medien“.
|
||||
*/
|
||||
private function usageLabel(PillarService $service, Pillar $pillar): string
|
||||
{
|
||||
$usage = [
|
||||
'medien' => (int) $pillar->elements_count,
|
||||
'zusammenstellungen' => (int) $pillar->compositions_count,
|
||||
'lizenzartikel' => (int) $pillar->license_articles_count,
|
||||
'seiten' => (int) $pillar->pages_count,
|
||||
];
|
||||
|
||||
return array_sum($usage) === 0 ? '0 Medien' : $service->usageText($usage);
|
||||
}
|
||||
|
||||
protected function catalogRows(): array
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
foreach (Pillar::query()->withCount('elements')->orderBy('sort_order')->orderBy('name')->get() as $pillar) {
|
||||
$service = app(PillarService::class);
|
||||
|
||||
foreach (Pillar::query()->withCount(['elements', 'compositions', 'licenseArticles', 'pages'])->orderBy('sort_order')->orderBy('name')->get() as $pillar) {
|
||||
$public = $pillar->published_at !== null;
|
||||
$url = PillarResource::getUrl('edit', ['record' => $pillar]);
|
||||
$rows[] = [
|
||||
@@ -66,7 +83,7 @@ protected function catalogRows(): array
|
||||
'url' => $url,
|
||||
'chips' => [
|
||||
$public ? ['label' => 'Auf der Website veröffentlicht', 'ton' => 'gut'] : ['label' => 'Intern', 'ton' => 'leise'],
|
||||
['label' => $pillar->elements_count === 1 ? '1 Medium' : $pillar->elements_count.' Medien', 'ton' => 'neutral'],
|
||||
['label' => $this->usageLabel($service, $pillar), 'ton' => 'neutral'],
|
||||
],
|
||||
'zustand' => [$public ? 'oeffentlich' : 'intern'],
|
||||
'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']],
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
|
||||
/**
|
||||
* Fachliche Säulen im Redaktionsmanager von Modul, Programm und Lizenzartikel (wie bei Medien): Die Auswahl kommt aus
|
||||
* der zentralen Säulenverwaltung, die Zuordnung ersetzt die bisherige vollständig und bleibt beim Speichern anderer
|
||||
* Angaben erhalten, weil der gespeicherte Stand geladen und mitgeschrieben wird.
|
||||
*
|
||||
* Eine Zuordnung veröffentlicht nichts: Ob eine Säule eine Themenseite hat, entscheidet allein die Säulenverwaltung.
|
||||
*/
|
||||
trait AssignsPillars
|
||||
{
|
||||
/** @var list<int|string> */
|
||||
public array $pillarIds = [];
|
||||
|
||||
/**
|
||||
* @return array{legend: string, model: string, values: list<array{id: int, label: string}>}|null
|
||||
*/
|
||||
public function pillarGroup(): ?array
|
||||
{
|
||||
$values = Pillar::query()->orderBy('sort_order')->orderBy('name')->get(['id', 'name'])
|
||||
->map(fn (Pillar $pillar): array => ['id' => (int) $pillar->id, 'label' => (string) $pillar->name])
|
||||
->all();
|
||||
|
||||
return $values === [] ? null : ['legend' => 'Fachliche Säulen', 'model' => 'pillarIds', 'values' => $values];
|
||||
}
|
||||
|
||||
protected function loadPillarIds(Composition|LicenseArticle $subject): void
|
||||
{
|
||||
$this->pillarIds = $subject->pillars()->pluck('pillars.id')->map(fn (mixed $id): string => (string) (int) $id)->all();
|
||||
}
|
||||
|
||||
protected function persistPillarIds(Composition|LicenseArticle $subject): void
|
||||
{
|
||||
app(PillarService::class)->assign($subject, array_map(intval(...), $this->pillarIds));
|
||||
}
|
||||
|
||||
protected function pillarsUnsaved(Composition|LicenseArticle $subject): bool
|
||||
{
|
||||
$stored = $subject->pillars()->pluck('pillars.id')->map(fn (mixed $id): int => (int) $id)->all();
|
||||
$current = array_map(intval(...), $this->pillarIds);
|
||||
sort($stored);
|
||||
sort($current);
|
||||
|
||||
return $stored !== $current;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Http\Controllers\ContentPreviewController;
|
||||
@@ -27,6 +28,9 @@ trait ChoosesMedia
|
||||
|
||||
public string $pickerDimension = '';
|
||||
|
||||
/** Filter „Fachliche Säule“ (Kennung der Säule aus der zentralen Säulenverwaltung). */
|
||||
public string $pickerSaeule = '';
|
||||
|
||||
/** Filter „Fachliche Materialart“ (Kennung), gleiche Regel wie Medieneditor und Medienfilter. */
|
||||
public string $pickerMaterialart = '';
|
||||
|
||||
@@ -108,6 +112,8 @@ public function pickerResult(): array
|
||||
$this->pickerKind,
|
||||
$this->pickerDimension,
|
||||
$this->pickerExceptId(),
|
||||
false,
|
||||
ctype_digit($this->pickerSaeule) ? (int) $this->pickerSaeule : 0,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -204,6 +210,7 @@ protected function resetPicker(string $purpose): void
|
||||
$this->pickerOpen = true;
|
||||
$this->pickerQuery = '';
|
||||
$this->pickerDimension = '';
|
||||
$this->pickerSaeule = '';
|
||||
$this->pickerMaterialart = '';
|
||||
$this->pickerInspected = '';
|
||||
$this->pickerSelected = '';
|
||||
@@ -239,6 +246,17 @@ private function filterByMaterialart(array $result): array
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Säulen für den Picker-Filter, in der Reihenfolge der Säulenverwaltung.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function pickerSaeulen(): array
|
||||
{
|
||||
return Pillar::query()->orderBy('sort_order')->orderBy('name')->pluck('name', 'id')
|
||||
->mapWithKeys(fn (string $name, int|string $id): array => [(string) $id => $name])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Einordnungsfilter des Pickers: dieselbe Filterregel wie Medien- und Kompositionslisten (verwendete inaktive Werte
|
||||
* bleiben auffindbar, ein gewählter Filter bleibt sichtbar).
|
||||
|
||||
@@ -2,8 +2,14 @@
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Media\CompositionStill;
|
||||
use App\Domain\Media\FilmStill;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
/**
|
||||
@@ -31,6 +37,128 @@ public function openWebsiteImagePicker(string $pfad): void
|
||||
$this->forceRenderForPicker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte: das Vorschaubild des Films als Bild für die Website übernehmen. Es entsteht ein Bild
|
||||
* im Medienmanager (einmal gespeichert), das im Bildfeld ausgewählt wird. Die Datei des Films bleibt geschützt.
|
||||
*/
|
||||
public function adoptFilmThumbnail(string $pfad, int $elementId): void
|
||||
{
|
||||
$this->adoptFilmStill($pfad, $elementId, fn (FilmStill $stills, ContentElement $film): ContentElement => $stills->fromThumbnail($film, auth('staff')->user()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte: eine Stelle des Films wählen und als Bild für die Website übernehmen.
|
||||
*/
|
||||
public function adoptFilmFrame(string $pfad, int $elementId, string $sekunde): void
|
||||
{
|
||||
if (! is_numeric($sekunde)) {
|
||||
Notification::make()->danger()->title('Bitte eine Zeitposition in Sekunden angeben.')->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->adoptFilmStill($pfad, $elementId, fn (FilmStill $stills, ContentElement $film): ContentElement => $stills->fromSecond($film, (float) $sekunde, auth('staff')->user()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Programm- und Modulkarte: das Vorschaubild des Programms oder Moduls als Bild für die Website übernehmen
|
||||
* (Bild-Medium im Medienmanager, einmal kopiert).
|
||||
*/
|
||||
public function adoptCompositionThumbnail(string $pfad, int $compositionId): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
if ($this->imageTargetIsInvalid($pfad)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$composition = Composition::query()->find($compositionId);
|
||||
|
||||
if (! $composition instanceof Composition) {
|
||||
return;
|
||||
}
|
||||
|
||||
$stills = app(CompositionStill::class);
|
||||
|
||||
try {
|
||||
$still = $stills->fromThumbnail($composition, auth('staff')->user());
|
||||
} catch (DomainRuleException $exception) {
|
||||
Notification::make()->danger()->title($exception->getMessage())->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data_set($this, $pfad, $still->id);
|
||||
$this->announceAdoptedStill($still, $stills->reused, 'Dieses Vorschaubild war schon übernommen.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable(FilmStill, ContentElement): ContentElement $make
|
||||
*/
|
||||
private function adoptFilmStill(string $pfad, int $elementId, callable $make): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
if ($this->imageTargetIsInvalid($pfad)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$film = ContentElement::query()->with('editorialContentKind')->find($elementId);
|
||||
|
||||
if (! $film instanceof ContentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
$stills = app(FilmStill::class);
|
||||
|
||||
try {
|
||||
$still = $make($stills, $film);
|
||||
} catch (DomainRuleException $exception) {
|
||||
Notification::make()->danger()->title($exception->getMessage())->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data_set($this, $pfad, $still->id);
|
||||
$this->announceAdoptedStill($still, $stills->reused, 'Diese Stelle war schon übernommen.');
|
||||
}
|
||||
|
||||
/** Nur das Bildfeld eines Widgets oder Abschnitts ist ein zulässiges Ziel (…image). */
|
||||
private function imageTargetIsInvalid(string $pfad): bool
|
||||
{
|
||||
return preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+\.image$/', $pfad) !== 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meldung nach dem tatsächlichen Stand des Bildes: neu angelegt, schon vorhanden und freigegeben, wird verarbeitet
|
||||
* oder Website-Freigabe zurückgenommen (bleibt zurückgenommen).
|
||||
*/
|
||||
private function announceAdoptedStill(ContentElement $still, bool $reused, string $reusedText): void
|
||||
{
|
||||
$title = ($still->display_title ?: $still->working_title);
|
||||
|
||||
if (! $reused) {
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Im Medienmanager angelegt: „'.$title.'“')
|
||||
->body('Das Bild ist als Kartenbild ausgewählt. Nach der Verarbeitung wird es für die Website freigegeben; dort lässt sich die Freigabe auch zurücknehmen.')
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (app(WebsiteMedia::class)->present($still) !== null) {
|
||||
Notification::make()->success()->title('Bereits im Medienmanager: „'.$title.'“')->body($reusedText.' Das Bild ist als Kartenbild ausgewählt.')->send();
|
||||
} elseif (blank($still->thumbnail_path) && blank($still->thumbnail_error)) {
|
||||
Notification::make()->success()->title('Bereits im Medienmanager: „'.$title.'“')->body('Das Bild wird noch verarbeitet und danach für die Website freigegeben.')->send();
|
||||
} else {
|
||||
Notification::make()->warning()->title('Bild ausgewählt, aber nicht für die Website freigegeben: „'.$title.'“')
|
||||
->body($reusedText.' Die Website-Freigabe wurde zurückgenommen. Das Bild erscheint öffentlich erst wieder, wenn sie im Medienmanager (Reiter „Website“) erneut gegeben wird.')
|
||||
->persistent()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filament rendert bei offenen Aktionsdialogen nur den Dialogteil neu; der Picker liegt darüber und braucht die
|
||||
* ganze Seite.
|
||||
|
||||
@@ -272,7 +272,7 @@ public function search(string $query, string $scope, int $exceptCompositionId):
|
||||
/**
|
||||
* @return array{items: list<array<string, string|null>>, more: bool}
|
||||
*/
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false): array
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false, int $pillarId = 0): array
|
||||
{
|
||||
$query = trim($query);
|
||||
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
||||
@@ -284,8 +284,8 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
$latestElements = ContentElementVersion::query()
|
||||
->selectRaw('MAX(id)')
|
||||
->whereIn('status', [ContentVersionStatus::Bereit, ContentVersionStatus::Entwurf])
|
||||
->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId): void {
|
||||
$this->constrainElement($builder, $query, $like, $kind, $dimensionId);
|
||||
->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId, $pillarId): void {
|
||||
$this->constrainElement($builder, $query, $like, $kind, $dimensionId, $pillarId);
|
||||
})
|
||||
->groupBy('content_element_id');
|
||||
$elements = ContentElementVersion::query()
|
||||
@@ -309,7 +309,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
->selectRaw('MAX(id)')
|
||||
->where('status', ContentVersionStatus::Bereit)
|
||||
->where('composition_id', '!=', $exceptCompositionId)
|
||||
->whereHas('composition', function ($builder) use ($query, $like, $kind, $dimensionId): void {
|
||||
->whereHas('composition', function ($builder) use ($query, $like, $kind, $dimensionId, $pillarId): void {
|
||||
if ($kind === 'modul') {
|
||||
$builder->where('kind', CompositionKind::Uebung);
|
||||
}
|
||||
@@ -318,6 +318,10 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
$builder->whereIn('id', $this->dimensionSubjectIds(Composition::class, $dimensionId));
|
||||
}
|
||||
|
||||
if ($pillarId > 0) {
|
||||
$builder->whereIn('id', $this->pillarSubjectIds(Composition::class, $pillarId));
|
||||
}
|
||||
|
||||
if ($query === '') {
|
||||
return;
|
||||
}
|
||||
@@ -370,6 +374,10 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($pillarId > 0 && ! in_array($composition->id, $this->pillarSubjectIds(Composition::class, $pillarId), true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = $this->compositionTitle($composition);
|
||||
|
||||
if ($query !== '' && ! str_contains(mb_strtolower($title.' '.(string) ($composition->summary ?? '')), mb_strtolower($query))) {
|
||||
@@ -564,7 +572,7 @@ private function withVisibility(array $rows): array
|
||||
/**
|
||||
* @param Builder<ContentElement> $builder
|
||||
*/
|
||||
private function constrainElement($builder, string $query, string $like, string $kind, int $dimensionId): void
|
||||
private function constrainElement($builder, string $query, string $like, string $kind, int $dimensionId, int $pillarId = 0): void
|
||||
{
|
||||
$outputs = match ($kind) {
|
||||
'film' => ['film'],
|
||||
@@ -583,6 +591,10 @@ private function constrainElement($builder, string $query, string $like, string
|
||||
$builder->whereIn('id', $this->dimensionSubjectIds(ContentElement::class, $dimensionId));
|
||||
}
|
||||
|
||||
if ($pillarId > 0) {
|
||||
$builder->whereIn('id', $this->pillarSubjectIds(ContentElement::class, $pillarId));
|
||||
}
|
||||
|
||||
if ($query === '') {
|
||||
return;
|
||||
}
|
||||
@@ -597,6 +609,22 @@ private function constrainElement($builder, string $query, string $like, string
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkt einer Säule zugeordnete Medien oder Module und Programme (zentrale Säulenverwaltung).
|
||||
*
|
||||
* @param class-string<Model> $class
|
||||
* @return list<int>
|
||||
*/
|
||||
private function pillarSubjectIds(string $class, int $pillarId): array
|
||||
{
|
||||
[$table, $column] = $class === Composition::class
|
||||
? ['composition_pillar', 'composition_id']
|
||||
: ['content_element_pillar', 'content_element_id'];
|
||||
|
||||
return DB::table($table)->where('pillar_id', $pillarId)->pluck($column)
|
||||
->map(fn (mixed $id): int => (int) $id)->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $class
|
||||
* @return list<int>
|
||||
|
||||
@@ -7,9 +7,12 @@
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarFilterCompat;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
/**
|
||||
@@ -29,6 +32,10 @@ trait ListsCompositions
|
||||
#[Url]
|
||||
public string $pillar = '';
|
||||
|
||||
/** Fachliche Säule (zentrale Säulenverwaltung), direkt zugeordnet. */
|
||||
#[Url(as: 'saeule', except: '')]
|
||||
public string $saeule = '';
|
||||
|
||||
#[Url]
|
||||
public string $visibility = 'alle';
|
||||
|
||||
@@ -39,7 +46,7 @@ protected function fixedKind(): ?CompositionKind
|
||||
|
||||
protected function bestandFilterEigenschaften(): array
|
||||
{
|
||||
return ['query', 'kindFilter', 'pillar', 'visibility'];
|
||||
return ['query', 'kindFilter', 'pillar', 'saeule', 'visibility'];
|
||||
}
|
||||
|
||||
public function resetFilters(): void
|
||||
@@ -47,13 +54,14 @@ public function resetFilters(): void
|
||||
$this->query = '';
|
||||
$this->kindFilter = 'alle';
|
||||
$this->pillar = '';
|
||||
$this->saeule = '';
|
||||
$this->visibility = 'alle';
|
||||
$this->bestandGrenze = Bestand::SCHRITT;
|
||||
}
|
||||
|
||||
public function hasActiveFilters(): bool
|
||||
{
|
||||
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->visibility !== 'alle';
|
||||
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->saeule !== '' || $this->visibility !== 'alle';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,6 +69,7 @@ public function hasActiveFilters(): bool
|
||||
*/
|
||||
public function bestand(): array
|
||||
{
|
||||
$this->normalizeLegacyPillarFilter();
|
||||
$fixed = $this->fixedKind();
|
||||
$einheit = match ($fixed) {
|
||||
CompositionKind::Kurs => ['Programm', 'Programme'],
|
||||
@@ -90,9 +99,14 @@ public function bestand(): array
|
||||
'eigenschaft' => 'visibility', 'label' => 'Stand', 'vorgabe' => 'alle',
|
||||
'optionen' => ['alle' => 'Jeder Stand', 'bibliothek' => 'In der Mitgliederbibliothek', 'verborgen' => 'Nicht in der Mitgliederbibliothek', 'entwurf' => 'Noch ohne Fassung'],
|
||||
]],
|
||||
'weitere' => $gruppen === [] ? [] : [[
|
||||
'eigenschaft' => 'pillar', 'label' => 'Fachliche Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'gruppen' => $gruppen,
|
||||
]],
|
||||
'weitere' => [
|
||||
...($this->pillarOptions() === [] ? [] : [[
|
||||
'eigenschaft' => 'saeule', 'label' => 'Fachliche Säule', 'vorgabe' => '', 'alle' => 'Alle Säulen', 'optionen' => $this->pillarOptions(),
|
||||
]]),
|
||||
...($gruppen === [] ? [] : [[
|
||||
'eigenschaft' => 'pillar', 'label' => 'Fachliche Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'gruppen' => $gruppen,
|
||||
]]),
|
||||
],
|
||||
'zeilen' => $this->entries(),
|
||||
'einheit' => $einheit,
|
||||
'leer' => [
|
||||
@@ -124,7 +138,9 @@ public function entries(): array
|
||||
$needle = mb_strtolower(trim($this->query));
|
||||
$catalog = app(EditorialCatalog::class);
|
||||
$offered = $catalog->offeredCompositionIds();
|
||||
$this->normalizeLegacyPillarFilter();
|
||||
$pillarIds = $this->pillar === '' ? null : $this->pillarSubjects((int) $this->pillar);
|
||||
$saeuleIds = ctype_digit($this->saeule) && $this->saeule !== '' ? $this->saeuleSubjects((int) $this->saeule) : null;
|
||||
$fixed = $this->fixedKind();
|
||||
$kinds = $fixed !== null ? [$fixed] : match ($this->kindFilter) {
|
||||
'programm' => [CompositionKind::Kurs],
|
||||
@@ -149,6 +165,10 @@ public function entries(): array
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($saeuleIds !== null && ! in_array($composition->id, $saeuleIds, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$stand = $catalog->stand($composition);
|
||||
|
||||
if (! $this->matchesVisibility($stand)) {
|
||||
@@ -249,6 +269,36 @@ private function coverMembers(Composition $composition): array
|
||||
return $members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alte Adressen mit einem Säulenwert der Einordnung (`?pillar=…`) gelten für die zentrale Säule.
|
||||
*/
|
||||
private function normalizeLegacyPillarFilter(): void
|
||||
{
|
||||
if (ctype_digit($this->pillar) && $this->pillar !== '' && $this->saeule === '' && is_int($pillar = PillarFilterCompat::pillarOfLegacyValue((int) $this->pillar))) {
|
||||
[$this->saeule, $this->pillar] = [(string) $pillar, ''];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function pillarOptions(): array
|
||||
{
|
||||
return Pillar::query()->orderBy('sort_order')->orderBy('name')->pluck('name', 'id')
|
||||
->mapWithKeys(fn (string $name, int|string $id): array => [(string) $id => $name])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkt zugeordnete Module und Programme einer Säule. Die Säulen der enthaltenen Medien zählen hier nicht.
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
private function saeuleSubjects(int $pillarId): array
|
||||
{
|
||||
return DB::table('composition_pillar')->where('pillar_id', $pillarId)->pluck('composition_id')
|
||||
->map(fn (mixed $id): int => (int) $id)->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarFilterCompat;
|
||||
use App\Domain\Catalog\ReleaseContent;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
@@ -132,6 +133,13 @@ public function cards(array $filters, bool $canEdit): array
|
||||
*/
|
||||
private function normalize(array $filters): array
|
||||
{
|
||||
$saeule = ctype_digit($filters['saeule'] ?? '') ? $filters['saeule'] : '';
|
||||
$einordnung = ctype_digit($filters['einordnung'] ?? '') ? $filters['einordnung'] : '';
|
||||
|
||||
if ($einordnung !== '' && $saeule === '' && is_int($pillar = PillarFilterCompat::pillarOfLegacyValue((int) $einordnung))) {
|
||||
[$saeule, $einordnung] = [(string) $pillar, ''];
|
||||
}
|
||||
|
||||
return [
|
||||
'suche' => trim($filters['suche'] ?? ''),
|
||||
'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
|
||||
@@ -139,8 +147,8 @@ private function normalize(array $filters): array
|
||||
'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']),
|
||||
'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']),
|
||||
'nutzung' => $this->choice($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']),
|
||||
'saeule' => ctype_digit($filters['saeule'] ?? '') ? $filters['saeule'] : '',
|
||||
'einordnung' => ctype_digit($filters['einordnung'] ?? '') ? $filters['einordnung'] : '',
|
||||
'saeule' => $saeule,
|
||||
'einordnung' => $einordnung,
|
||||
'inhaltsart' => ctype_digit($filters['inhaltsart'] ?? '') ? $filters['inhaltsart'] : '',
|
||||
'verarbeitung' => $this->choice($filters['verarbeitung'] ?? '', ['fehler', 'uebernahme']),
|
||||
'archiv' => $this->choice($filters['archiv'] ?? '', ['aktiv', 'archiviert', 'alle'], 'aktiv'),
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\BundleStatus;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\ReleaseStatus;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Voraussetzungen bis zur Veröffentlichung für Lizenzartikel, Paket und Angebot in einer gemeinsamen Form
|
||||
* (Verwaltungsstandard 14, Abschnitt 9: eine Komponente für gleiche Aufgaben). Die Klasse liest nur; sie ändert keine
|
||||
* fachliche Regel. Jeder Schritt nennt, was fehlt, und bietet den Weg dorthin an.
|
||||
*
|
||||
* Schritt: ['titel', 'text', 'stand' => erledigt|offen|optional, 'aktion' => ['label', 'wire'|'href']|null]
|
||||
* Ergebnis: ['schritte', 'bereit' (alle Pflichtschritte erledigt), 'naechster' (Text des ersten offenen Pflichtschritts)].
|
||||
*/
|
||||
class PublicationReadiness
|
||||
{
|
||||
public function __construct(
|
||||
private readonly BundleService $bundles,
|
||||
private readonly OfferService $offers,
|
||||
private readonly PublicCatalogReader $catalog,
|
||||
) {}
|
||||
|
||||
/** Ein Artikel ist verwendbar, wenn sein aktueller Stand veröffentlicht ist. */
|
||||
public function articleUsable(LicenseArticle $article): bool
|
||||
{
|
||||
$release = $article->currentRelease;
|
||||
|
||||
return $release instanceof ArticleRelease && StatusValue::of($release->status) === ReleaseStatus::Veroeffentlicht->value;
|
||||
}
|
||||
|
||||
/** Anzeige in Auswahllisten: Name, Kennung und Stand statt der bloßen Kennung. */
|
||||
public function articleLabel(LicenseArticle $article): string
|
||||
{
|
||||
$title = $this->articleName($article);
|
||||
$name = $title !== '' ? $title.' ('.$article->code.')' : (string) $article->code;
|
||||
$release = $article->currentRelease;
|
||||
|
||||
if ($this->articleUsable($article)) {
|
||||
return $name.' · Stand '.$release->number;
|
||||
}
|
||||
|
||||
return $name.' · '.($release === null ? 'noch ohne Stand, nicht verwendbar' : 'Stand gesperrt, nicht verwendbar');
|
||||
}
|
||||
|
||||
/** Name wie in der Redaktion: eigener Name oder Name des Inhalts, sonst der Arbeitstitel; leer ohne beides. */
|
||||
public function articleName(LicenseArticle $article): string
|
||||
{
|
||||
return app(ProductOptions::class)->articleName($article);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function articleOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (LicenseArticle::query()->with('currentRelease')->orderBy('code')->get() as $article) {
|
||||
$options[$article->id] = $this->articleLabel($article);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Veröffentlichte Paketfassungen mit ihren Artikeln, damit die Auswahl zeigt, was verkauft wird.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function bundleVersionOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (BundleVersion::query()->where('status', BundleStatus::Veroeffentlicht)->with('bundle')->orderBy('id')->get() as $version) {
|
||||
try {
|
||||
$codes = LicenseArticle::query()->whereIn('id', $this->bundles->articleIds($version))->orderBy('code')->pluck('code')->all();
|
||||
} catch (DomainRuleException) {
|
||||
$codes = [];
|
||||
}
|
||||
|
||||
$options[$version->id] = $version->bundle->name.' · Fassung '.$version->number.' ('.($codes === [] ? 'ohne Artikel' : implode(', ', $codes)).')';
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Artikel einer Auswahl, die keinen verwendbaren Stand haben.
|
||||
*
|
||||
* @param list<int> $articleIds
|
||||
* @return list<LicenseArticle>
|
||||
*/
|
||||
public function unusableArticles(array $articleIds): array
|
||||
{
|
||||
return LicenseArticle::query()->with('currentRelease')->whereIn('id', array_unique($articleIds))->orderBy('code')->get()
|
||||
->reject(fn (LicenseArticle $article): bool => $this->articleUsable($article))
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<LicenseArticle> $articles
|
||||
*/
|
||||
public function unusableMessage(array $articles, string $zweck): string
|
||||
{
|
||||
$namen = implode(', ', array_map(fn (LicenseArticle $article): string => '„'.($this->articleName($article) ?: $article->code).'“ ('.$article->code.')', $articles));
|
||||
|
||||
return (count($articles) === 1 ? 'Der Lizenzartikel ' : 'Die Lizenzartikel ').$namen
|
||||
.(count($articles) === 1 ? ' hat' : ' haben')
|
||||
.' noch keinen veröffentlichten Stand und vergibt'.(count($articles) === 1 ? '' : ' keine').' keine Inhalte. '
|
||||
.'Lege zuerst am Artikel mit „Inhalt festlegen“ den Inhalt fest, bevor du '.$zweck.'.';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function forArticle(LicenseArticle $article): array
|
||||
{
|
||||
$article->loadMissing('currentRelease');
|
||||
$usable = $this->articleUsable($article);
|
||||
$release = $article->currentRelease;
|
||||
$inUse = $this->articleInUse($article);
|
||||
|
||||
return $this->result([
|
||||
[
|
||||
'titel' => 'Inhalt festlegen',
|
||||
'text' => $usable
|
||||
? 'Stand '.$release->number.' ist veröffentlicht und bestimmt, welche Inhalte der Artikel lizenziert.'
|
||||
: 'Der Artikel lizenziert noch nichts. Wähle den freigegebenen Inhalt (Medium, Modul oder Programm), den er umfassen soll.',
|
||||
'stand' => $usable ? 'erledigt' : 'offen',
|
||||
'aktion' => $usable ? null : ['label' => 'Inhalt festlegen', 'wire' => "mountAction('release')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'Name und Beschreibung',
|
||||
'text' => $this->articleName($article) !== ''
|
||||
? 'Der Name „'.$this->articleName($article).'“ erscheint in Paketen, Angeboten, im Shop und in der Bibliothek.'
|
||||
: 'Ohne Name erscheint die Kennung „'.$article->code.'“. Name, Teaser und Beschreibung pflegst du in der Redaktion.',
|
||||
'stand' => $this->articleName($article) !== '' ? 'erledigt' : 'optional',
|
||||
'aktion' => $this->articleName($article) !== '' ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'In einem Paket oder Angebot verwenden',
|
||||
'text' => $inUse
|
||||
? 'Der Artikel ist in einem Paket oder Angebot enthalten.'
|
||||
: 'Verkauft wird der Artikel erst über ein Angebot, allein oder in einem Paket.',
|
||||
'stand' => $inUse ? 'erledigt' : 'offen',
|
||||
'aktion' => $inUse ? null : ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')],
|
||||
'pflicht' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function forBundle(Bundle $bundle): array
|
||||
{
|
||||
$published = $bundle->versions()->where('status', BundleStatus::Veroeffentlicht)->orderByDesc('number')->first();
|
||||
$missing = [];
|
||||
|
||||
if ($published instanceof BundleVersion) {
|
||||
try {
|
||||
$missing = $this->unusableArticles($this->bundles->articleIds($published));
|
||||
} catch (DomainRuleException) {
|
||||
$missing = [];
|
||||
}
|
||||
}
|
||||
|
||||
$offered = $published instanceof BundleVersion && $this->bundleOffered($bundle);
|
||||
|
||||
return $this->result([
|
||||
[
|
||||
'titel' => 'Bestandteile festlegen',
|
||||
'text' => $published instanceof BundleVersion
|
||||
? 'Fassung '.$published->number.' ist veröffentlicht und unveränderlich.'
|
||||
: 'Wähle die Lizenzartikel und Pakete, die zusammen verkauft werden, und veröffentliche die Fassung.',
|
||||
'stand' => $published instanceof BundleVersion ? 'erledigt' : 'offen',
|
||||
'aktion' => $published instanceof BundleVersion ? null : ['label' => 'Bestandteile festlegen', 'wire' => "mountAction('publish')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'Jeder enthaltene Artikel hat einen Inhalt',
|
||||
'text' => ! $published instanceof BundleVersion
|
||||
? 'Wird geprüft, sobald die Bestandteile feststehen.'
|
||||
: ($missing === []
|
||||
? 'Alle enthaltenen Artikel haben einen veröffentlichten Stand.'
|
||||
: 'Ohne Stand und damit ohne Inhalt: '.implode(', ', array_map(fn (LicenseArticle $article): string => (string) $article->code, $missing)).'. Ein Angebot lässt sich erst aktivieren, wenn jeder Artikel einen Stand hat.'),
|
||||
'stand' => $published instanceof BundleVersion && $missing === [] ? 'erledigt' : 'offen',
|
||||
'aktion' => $missing === [] ? null : ['label' => 'Artikel „'.$missing[0]->code.'“ öffnen', 'href' => LicenseArticleResource::getUrl('view', ['record' => $missing[0]])],
|
||||
],
|
||||
[
|
||||
'titel' => 'Angebot mit Preis und Rechten',
|
||||
'text' => $offered
|
||||
? 'Ein aktives Angebot verkauft dieses Paket.'
|
||||
: 'Verkauft wird das Paket erst über ein Angebot. Dort wählst du die Paketfassung, die Rechte und den Preis.',
|
||||
'stand' => $offered ? 'erledigt' : 'offen',
|
||||
'aktion' => $offered ? null : ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')],
|
||||
'pflicht' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function forOffer(Offer $offer): array
|
||||
{
|
||||
$active = $offer->versions()->where('status', 'aktiv')->orderByDesc('number')->first();
|
||||
$hasActive = $active instanceof OfferVersion;
|
||||
$articleIds = $hasActive ? $active->resolvedScopes()->pluck('license_article_id')->map(fn ($id): int => (int) $id)->all() : [];
|
||||
$missing = $this->unusableArticles($articleIds);
|
||||
$buyable = $hasActive && $this->offers->purchasableVersion($offer) !== null;
|
||||
$page = $offer->composition;
|
||||
$shown = $page !== null && $this->catalog->shownVersion($page) !== null;
|
||||
$pageName = $page !== null ? (string) ($page->display_title ?: $page->designation) : '';
|
||||
$activate = ['label' => $hasActive ? 'Geänderte Fassung aktivieren' : 'Angebot konfigurieren', 'wire' => "mountAction('activate')"];
|
||||
|
||||
return $this->result([
|
||||
[
|
||||
'titel' => 'Artikel oder Paket, Rechte, Preis und Vergabe festlegen',
|
||||
'text' => $hasActive
|
||||
? 'Fassung '.$active->number.' ist aktiv.'
|
||||
: 'Wähle, was verkauft wird (Lizenzartikel oder Paketfassung), welche Nutzungsrechte dazugehören, für wen es gilt und was es kostet. Erst „Fassung aktivieren“ macht das Angebot gültig.',
|
||||
'stand' => $hasActive ? 'erledigt' : 'offen',
|
||||
'aktion' => $hasActive ? null : $activate,
|
||||
],
|
||||
[
|
||||
'titel' => 'Inhalt vorhanden',
|
||||
'text' => ! $hasActive
|
||||
? 'Wird geprüft, sobald die Fassung aktiv ist.'
|
||||
: ($missing === []
|
||||
? 'Jeder enthaltene Lizenzartikel hat einen veröffentlichten Stand.'
|
||||
: 'Ohne Stand und damit ohne Inhalt: '.implode(', ', array_map(fn (LicenseArticle $article): string => (string) $article->code, $missing)).'. Käufer würden nichts erhalten.'),
|
||||
'stand' => $hasActive && $missing === [] ? 'erledigt' : 'offen',
|
||||
'aktion' => $missing === [] ? null : ['label' => 'Artikel „'.$missing[0]->code.'“ öffnen', 'href' => LicenseArticleResource::getUrl('view', ['record' => $missing[0]])],
|
||||
],
|
||||
[
|
||||
'titel' => 'Als Kauf mit Preis angeboten',
|
||||
'text' => $buyable
|
||||
? 'Die aktive Fassung ist ein Kauf zu '.Money::format((int) $active->price_cents).'.'
|
||||
: ($hasActive ? 'Die aktive Fassung ist kein Kauf mit Preis (Vergabe: '.CatalogLabels::vergabe($active).'). Im Shop erscheinen nur Käufe.' : 'Wird mit der Fassung festgelegt.'),
|
||||
'stand' => $buyable ? 'erledigt' : 'offen',
|
||||
'aktion' => $buyable ? null : ($hasActive ? $activate : null),
|
||||
],
|
||||
[
|
||||
'titel' => 'Produktseite zuordnen',
|
||||
'text' => $page !== null
|
||||
? 'Zugeordnet: „'.$pageName.'“. Optionen derselben Produktseite sind Alternativen im Warenkorb.'
|
||||
: 'Der Shop zeigt ein Angebot auf der Seite eines Programms. Wähle in der Maske die Produktseite. Ein Paket braucht eine eigene Produktseite, sonst ist es Alternative zu den Einzelangeboten dieser Seite.',
|
||||
'stand' => $page !== null ? 'erledigt' : 'offen',
|
||||
'aktion' => $page !== null ? null : $activate,
|
||||
],
|
||||
[
|
||||
'titel' => 'Produktseite öffentlich',
|
||||
'text' => $page === null
|
||||
? 'Wird geprüft, sobald eine Produktseite zugeordnet ist.'
|
||||
: ($shown
|
||||
? 'Das Programm ist zur Anzeige freigegeben. Das Angebot erscheint in der Shop-Suche und auf der Produktseite.'
|
||||
: 'Das Programm „'.$pageName.'“ ist nicht zur Anzeige freigegeben oder kein Programm. Das Angebot ist dort nicht auffindbar.'),
|
||||
'stand' => $shown ? 'erledigt' : 'offen',
|
||||
'aktion' => $page === null || $shown ? null : ['label' => 'Programm öffnen', 'href' => EditorialCatalog::editUrl($page)],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $schritte
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function result(array $schritte): array
|
||||
{
|
||||
$schritte = array_map(fn (array $schritt): array => ['pflicht' => true, 'aktion' => null, ...$schritt], $schritte);
|
||||
$naechster = null;
|
||||
|
||||
foreach ($schritte as $schritt) {
|
||||
if ($schritt['pflicht'] && $schritt['stand'] === 'offen') {
|
||||
$naechster = $schritt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'schritte' => $schritte,
|
||||
'bereit' => $naechster === null,
|
||||
'naechster' => $naechster,
|
||||
];
|
||||
}
|
||||
|
||||
private function articleInUse(LicenseArticle $article): bool
|
||||
{
|
||||
return DB::table('offer_lines')->where('license_article_id', $article->id)->exists()
|
||||
|| DB::table('bundle_items')->where('license_article_id', $article->id)->exists();
|
||||
}
|
||||
|
||||
private function bundleOffered(Bundle $bundle): bool
|
||||
{
|
||||
return DB::table('offer_lines')
|
||||
->join('offer_versions', 'offer_versions.id', '=', 'offer_lines.offer_version_id')
|
||||
->join('bundle_versions', 'bundle_versions.id', '=', 'offer_lines.bundle_version_id')
|
||||
->where('bundle_versions.bundle_id', $bundle->id)
|
||||
->where('offer_versions.status', 'aktiv')
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ public function verify(EmailVerificationRequest $request): RedirectResponse
|
||||
$request->fulfill();
|
||||
app(GrantIssuer::class)->grantRegistrationOffers($request->user());
|
||||
|
||||
return redirect()->route('member.dashboard');
|
||||
// Wer aus dem Warenkorb kam, kehrt nach der Bestätigung zur Kasse zurück (gespeichertes Ziel der Sitzung).
|
||||
return redirect()->intended(route('member.dashboard'));
|
||||
}
|
||||
|
||||
public function send(Request $request): RedirectResponse
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\OrderHolders;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Öffentlicher Warenkorb (Etappe 1, nur Testzahlung). Er ist vor der Anmeldung nutzbar; die Prüfung der
|
||||
* vorhandenen Rechte erfolgt, sobald ein Konto angemeldet ist.
|
||||
*/
|
||||
class CartController extends Controller
|
||||
{
|
||||
public function show(Request $request, Cart $cart, OrderHolders $holders): View
|
||||
{
|
||||
$user = $request->user();
|
||||
$review = $cart->review($user, $request->integer('bestellen_als') ?: null);
|
||||
|
||||
return view('shop.cart', [
|
||||
'review' => $review,
|
||||
'holders' => $user === null ? collect() : $holders->for($user),
|
||||
]);
|
||||
}
|
||||
|
||||
public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
||||
{
|
||||
$page = $offer->composition;
|
||||
$result = $page !== null && $catalog->shownVersion($page) !== null
|
||||
? $cart->add($offer)
|
||||
: Cart::UNAVAILABLE;
|
||||
$back = $this->productPage($offer);
|
||||
|
||||
return match ($result) {
|
||||
Cart::ADDED => $back->with('status', 'Die Option liegt im Warenkorb.'),
|
||||
Cart::PRESENT => $back->with('status', 'Diese Option liegt bereits im Warenkorb. Sie erscheint nur einmal.'),
|
||||
Cart::ALTERNATIVE => $back->with('shop.switch', $offer->id),
|
||||
default => $back->withErrors(['shop' => 'Diese Option ist gerade nicht erhältlich.']),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Ausdrücklicher Wechsel zwischen Alternativoptionen derselben Produktseite.
|
||||
*/
|
||||
public function switch(Offer $offer, Cart $cart): RedirectResponse
|
||||
{
|
||||
if (! $cart->switchTo($offer)) {
|
||||
return $this->productPage($offer)->withErrors(['shop' => 'Diese Option ist gerade nicht erhältlich.']);
|
||||
}
|
||||
|
||||
return redirect()->route('cart')->with('status', 'Die Option wurde gewechselt.');
|
||||
}
|
||||
|
||||
public function remove(Offer $offer, Cart $cart): RedirectResponse
|
||||
{
|
||||
$cart->remove($offer);
|
||||
|
||||
return redirect()->route('cart')->with('status', 'Die Position ist entfernt.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Käufer übernimmt den aktuell gezeigten Preis und die aktuellen Bedingungen einer Position.
|
||||
*/
|
||||
public function accept(Offer $offer, Cart $cart): RedirectResponse
|
||||
{
|
||||
$seen = $cart->items()[$offer->id]['price_cents'] ?? null;
|
||||
$cart->acceptCurrent($offer);
|
||||
$price = $cart->purchasable($offer)?->price_cents;
|
||||
|
||||
return redirect()->route('cart')->with('status', match (true) {
|
||||
$price === null => 'Die Option ist nicht mehr erhältlich.',
|
||||
$seen !== null && (int) $seen !== (int) $price => 'Der aktuelle Preis von '.Money::format($price).' ist übernommen.',
|
||||
default => 'Die aktuellen Bedingungen sind übernommen.',
|
||||
});
|
||||
}
|
||||
|
||||
private function productPage(Offer $offer): RedirectResponse
|
||||
{
|
||||
return $offer->composition_id !== null
|
||||
? redirect()->route('public.program', $offer->composition_id)
|
||||
: redirect()->route('cart');
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,11 @@
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Commerce\Order;
|
||||
use App\Domain\Commerce\OrderHolders;
|
||||
use App\Domain\Commerce\StaleOverview;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -48,10 +51,50 @@ public function place(Request $request, Offer $offer, Checkout $checkout): Redir
|
||||
return redirect()->route('member.order', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestellübersicht: zeigt die geprüften Positionen mit dem Inhaber, für den bestellt wird.
|
||||
*/
|
||||
public function checkout(Request $request, Cart $cart, OrderHolders $holders): View|RedirectResponse
|
||||
{
|
||||
if ($cart->count() === 0) {
|
||||
return redirect()->route('cart');
|
||||
}
|
||||
|
||||
$review = $cart->review($request->user(), $request->integer('bestellen_als') ?: null);
|
||||
|
||||
return view('shop.checkout', [
|
||||
'review' => $review,
|
||||
'holders' => $holders->for($request->user()),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt die Bestellung an, aber nur, wenn die serverseitige Prüfung zur gezeigten Übersicht passt.
|
||||
*/
|
||||
public function placeOrder(Request $request, Cart $cart, Checkout $checkout): RedirectResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'digest' => ['required', 'string'],
|
||||
'bestellen_als' => ['nullable', 'integer'],
|
||||
]);
|
||||
$holderId = isset($data['bestellen_als']) ? (int) $data['bestellen_als'] : null;
|
||||
$back = redirect()->route('checkout', array_filter(['bestellen_als' => $holderId]));
|
||||
|
||||
try {
|
||||
$order = $checkout->placeFromCart($request->user(), $cart, $holderId, $data['digest']);
|
||||
} catch (StaleOverview $exception) {
|
||||
return $back->withErrors(['checkout' => $exception->getMessage()]);
|
||||
} catch (DomainRuleException $exception) {
|
||||
return $back->withErrors(['checkout' => $exception->getMessage()]);
|
||||
}
|
||||
|
||||
return redirect()->route('member.order', $order)->with('status', 'Die Bestellung ist angelegt. Bestätige jetzt die Testzahlung.');
|
||||
}
|
||||
|
||||
public function show(Request $request, Order $order): View
|
||||
{
|
||||
abort_unless($order->user_id === $request->user()->id, 403);
|
||||
$order->load('lines.offerVersion.offer', 'payments');
|
||||
$order->load('lines.offerVersion.offer', 'lines.holder', 'payments', 'party', 'user');
|
||||
|
||||
return view('member.order', [
|
||||
'order' => $order,
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarFilterCompat;
|
||||
use App\Domain\Entitlement\DecideAccess;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
@@ -20,8 +22,10 @@
|
||||
use App\Http\CourseOutline;
|
||||
use App\Http\LibraryCatalog;
|
||||
use App\Http\SignedLink;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
@@ -35,8 +39,21 @@ public function index(Request $request, ?string $sicht = null): View
|
||||
$query = trim((string) $request->query('q', ''));
|
||||
$nutzung = (string) $request->query('nutzung', '');
|
||||
$dimensionIds = array_values(array_filter(array_map(intval(...), (array) $request->query('dimension', []))));
|
||||
$saeuleIds = array_values(array_filter(array_map(intval(...), (array) $request->query('saeule', []))));
|
||||
$dimensions = app(IdentityDimension::class);
|
||||
|
||||
// Alte Adressen: Säulen waren ein Wert der Einordnung. Mit belastbarer Verknüpfung gilt der Filter der Säule.
|
||||
foreach ($dimensionIds as $index => $valueId) {
|
||||
if (is_int($pillarId = PillarFilterCompat::pillarOfLegacyValue($valueId))) {
|
||||
$saeuleIds[] = $pillarId;
|
||||
unset($dimensionIds[$index]);
|
||||
}
|
||||
}
|
||||
|
||||
$dimensionIds = array_values($dimensionIds);
|
||||
$saeuleIds = array_values(array_unique($saeuleIds));
|
||||
$pillarOptions = $this->visiblePillars($catalog, $saeuleIds);
|
||||
|
||||
foreach (['programs', 'modules'] as $shelf) {
|
||||
if ($query !== '') {
|
||||
$catalog[$shelf] = array_values(array_filter(
|
||||
@@ -50,6 +67,12 @@ public function index(Request $request, ?string $sicht = null): View
|
||||
fn (array $card): bool => $dimensions->matches($card['composition'], $dimensionIds),
|
||||
));
|
||||
}
|
||||
if ($saeuleIds !== []) {
|
||||
$catalog[$shelf] = array_values(array_filter(
|
||||
$catalog[$shelf],
|
||||
fn (array $card): bool => $this->hasPillar($card['composition'], $saeuleIds),
|
||||
));
|
||||
}
|
||||
if (in_array($nutzung, ['nutzbar', 'teilweise', 'nicht enthalten'], true)) {
|
||||
$catalog[$shelf] = array_values(array_filter(
|
||||
$catalog[$shelf],
|
||||
@@ -79,6 +102,13 @@ function (array $card) use ($dimensions, $dimensionIds): bool {
|
||||
));
|
||||
}
|
||||
|
||||
if ($saeuleIds !== []) {
|
||||
$catalog['materials'] = array_values(array_filter(
|
||||
$catalog['materials'],
|
||||
fn (array $card): bool => $this->hasPillar($this->materialSubject($card), $saeuleIds),
|
||||
));
|
||||
}
|
||||
|
||||
if ($nutzung === 'teilweise' || $nutzung === 'nicht enthalten') {
|
||||
$catalog['materials'] = [];
|
||||
}
|
||||
@@ -89,11 +119,65 @@ function (array $card) use ($dimensions, $dimensionIds): bool {
|
||||
'sicht' => $sicht,
|
||||
'nutzung' => $nutzung,
|
||||
'dimensionIds' => $dimensionIds,
|
||||
'saeuleIds' => $saeuleIds,
|
||||
'filterPillars' => $pillarOptions,
|
||||
'filterDimensions' => app(EditorialVocabulary::class)->memberFilterDimensions(array_map(intval(...), $dimensionIds)),
|
||||
'libraryEmpty' => $untouched,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subjekt eines Materialkarte: Programm oder Modul, Medium oder der Artikel selbst.
|
||||
*
|
||||
* @param array<string, mixed> $card
|
||||
*/
|
||||
private function materialSubject(array $card): Model
|
||||
{
|
||||
$release = $card['article']->currentRelease;
|
||||
|
||||
return $release?->rootCompositionVersion?->composition
|
||||
?? $release?->rootElementVersion?->element
|
||||
?? $card['article'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkte Säulenzuordnung des Objekts selbst; die Säulen enthaltener Medien zählen hier nicht.
|
||||
*
|
||||
* @param list<int> $pillarIds
|
||||
*/
|
||||
private function hasPillar(Model $subject, array $pillarIds): bool
|
||||
{
|
||||
return $subject->pillars()->whereIn('pillars.id', $pillarIds)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Säulen für den Filter: nur solche, die ein sichtbares Objekt der Bibliothek tatsächlich trägt, und eine bereits
|
||||
* gewählte. So erscheinen neue oder interne Säulen ohne Zuordnung nicht in der Bibliothek.
|
||||
*
|
||||
* @param array<string, mixed> $catalog
|
||||
* @param list<int> $selected
|
||||
* @return Collection<int, Pillar>
|
||||
*/
|
||||
private function visiblePillars(array $catalog, array $selected)
|
||||
{
|
||||
$used = [];
|
||||
|
||||
foreach (array_merge($catalog['programs'], $catalog['modules']) as $card) {
|
||||
foreach ($card['composition']->pillars()->pluck('pillars.id') as $id) {
|
||||
$used[(int) $id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($catalog['materials'] as $card) {
|
||||
foreach ($this->materialSubject($card)->pillars()->pluck('pillars.id') as $id) {
|
||||
$used[(int) $id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return Pillar::query()->whereIn('id', array_values(array_unique([...array_keys($used), ...$selected])))
|
||||
->orderBy('sort_order')->orderBy('name')->get();
|
||||
}
|
||||
|
||||
public function programs(Request $request): View
|
||||
{
|
||||
return $this->index($request, 'programme');
|
||||
@@ -382,7 +466,7 @@ private function grantQuery(Request $request)
|
||||
{
|
||||
return Grant::query()
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $request->user()->party_id))
|
||||
->usableBy($request->user())
|
||||
->with('article.currentRelease')
|
||||
->orderBy('id');
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PublicCatalogController extends Controller
|
||||
@@ -14,7 +17,7 @@ public function index(PublicCatalogReader $catalog): View
|
||||
return view('public.programs', ['programs' => $catalog->publicPrograms()]);
|
||||
}
|
||||
|
||||
public function program(Composition $composition, PublicCatalogReader $catalog): View
|
||||
public function program(Composition $composition, PublicCatalogReader $catalog, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
$version = $catalog->shownVersion($composition);
|
||||
abort_if($version === null, 404);
|
||||
@@ -23,6 +26,9 @@ public function program(Composition $composition, PublicCatalogReader $catalog):
|
||||
'composition' => $composition,
|
||||
'version' => $version,
|
||||
'nodes' => app(CompositionStructureReader::class)->tree($version),
|
||||
'options' => Shop::enabled() ? $products->forComposition($composition) : [],
|
||||
'cart' => $cart,
|
||||
'switchTo' => session('shop.switch'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public function show(string $path, WebsiteMedia $media): StreamedResponse
|
||||
abort_if(str_contains($path, '..') || ! str_starts_with($path, 'cms/'), 404);
|
||||
|
||||
// Ein in den Medienmanager übernommenes Bild folgt dessen Website-Freigabe, auch unter der früheren Adresse.
|
||||
abort_if(WebsiteMediaAlias::isRetired($path), 404);
|
||||
|
||||
$alias = WebsiteMediaAlias::effectiveFor($path);
|
||||
abort_if($alias !== null && $media->present($alias->content_element_id) === null, 404);
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Durchsuchbarer Shop (Etappe 1): macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite
|
||||
* wie die Programmkacheln. Gelistet wird nur, was zur Anzeige freigegeben ist und mindestens eine kaufbare Option hat.
|
||||
*/
|
||||
class ShopController extends Controller
|
||||
{
|
||||
public function index(Request $request, ProductOptions $products, PublicCatalogReader $catalog): View
|
||||
{
|
||||
$term = trim((string) $request->query('suche', ''));
|
||||
$summaries = $products->summaries();
|
||||
$cards = [];
|
||||
|
||||
foreach (Composition::query()->whereIn('id', array_keys($summaries))->orderBy('designation')->get() as $composition) {
|
||||
$version = $catalog->shownVersion($composition);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = (string) ($composition->display_title ?: $composition->designation);
|
||||
$haystack = mb_strtolower($title.' '.$composition->teaser.' '.$composition->summary.' '.$composition->search_terms);
|
||||
|
||||
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $summaries[$composition->id];
|
||||
$cards[] = [
|
||||
'composition' => $composition,
|
||||
'title' => $title,
|
||||
'teaser' => (string) ($composition->teaser ?: $composition->summary),
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
return view('shop.index', ['cards' => $cards, 'term' => $term]);
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ private function grants(User $user): Collection
|
||||
{
|
||||
return Grant::query()
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||
->usableBy($user)
|
||||
->with([
|
||||
'article.currentRelease.rootCompositionVersion.composition.editorialContentKind',
|
||||
'article.currentRelease.rootElementVersion.element.editorialContentKind',
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Domain\Commerce\Shop;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Warenkorb und Kasse gibt es nur mit Testzahlung und nie in Produktion (Etappe 1 erteilt keine Produktivfreigabe).
|
||||
*/
|
||||
class EnsureShopEnabled
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
abort_unless(Shop::enabled(), 404);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,8 @@
|
||||
],
|
||||
|
||||
/*
|
||||
| Vorbereiteter Warenkorbzugang in der Kopfzeile. Der Warenkorb ist Teil des kommerziellen Anwendungssystems
|
||||
| und noch nicht umgesetzt; solange enabled false ist, erscheint kein Warenkorbsymbol.
|
||||
| Früher vorbereiteter Warenkorbzugang. Seit Etappe 1 folgt der Eintrag in der Kopfzeile dem Shop
|
||||
| (App\Domain\Commerce\Shop::enabled: Testzahlung, nie in Produktion). Diese Werte werden nicht mehr gelesen.
|
||||
*/
|
||||
'cart' => [
|
||||
'enabled' => (bool) env('LUF_CART_ENABLED', false),
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use App\Domain\Catalog\LegacyPillarAdoption;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Fachliche Säulen vereinheitlichen: Module, Programme und Lizenzartikel verwenden wie Medien und Seiten die zentrale
|
||||
* Säulenverwaltung (`pillars`) statt der Kopie „Fachliche Säule“ in den redaktionellen Dimensionen.
|
||||
*
|
||||
* Nur Ergänzungen: zwei Zuordnungstabellen (die Säule wird beim Löschen nie still entfernt, wie bei Medien und Seiten),
|
||||
* die Verknüpfung `pillar_id` an den alten Dimensionswerten und die einmalige, wiederholbare Übernahme durch
|
||||
* LegacyPillarAdoption. Alte Tabellen und Zeilen bleiben unverändert erhalten.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('composition_pillar', function (Blueprint $table) {
|
||||
$table->foreignId('composition_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('pillar_id')->constrained()->restrictOnDelete();
|
||||
$table->primary(['composition_id', 'pillar_id']);
|
||||
});
|
||||
|
||||
Schema::create('license_article_pillar', function (Blueprint $table) {
|
||||
$table->foreignId('license_article_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('pillar_id')->constrained()->restrictOnDelete();
|
||||
$table->primary(['license_article_id', 'pillar_id']);
|
||||
});
|
||||
|
||||
Schema::table('editorial_dimension_values', function (Blueprint $table) {
|
||||
$table->foreignId('pillar_id')->nullable()->after('editorial_dimension_id')->constrained('pillars')->nullOnDelete();
|
||||
});
|
||||
|
||||
$report = (new LegacyPillarAdoption)->run();
|
||||
|
||||
foreach (LegacyPillarAdoption::lines($report) as $line) {
|
||||
if ($line !== '') {
|
||||
Log::info('Säulenübernahme: '.$line);
|
||||
}
|
||||
}
|
||||
|
||||
if ($report['unresolved'] !== []) {
|
||||
Log::warning('Säulenübernahme: '.count($report['unresolved']).' Fälle ungeklärt; „php artisan luf:saeulen-uebernehmen --dry-run“ listet sie.');
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('editorial_dimension_values', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('pillar_id');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('license_article_pillar');
|
||||
Schema::dropIfExists('composition_pillar');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Herkunft der Standbilder, die aus einem Film als Bild-Medium übernommen wurden (Medien- und Materialkarte).
|
||||
* Additiv. Sie verhindert, dass dieselbe Filmstelle mehrfach als neues Medium entsteht, und hält fest, woher das
|
||||
* Bild kommt. Das Standbild selbst ist ein gewöhnliches Medium (output_class bild) mit eigener Website-Freigabe.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('film_still_sources', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('film_element_id')->constrained('content_elements')->restrictOnDelete();
|
||||
$table->foreignId('still_element_id')->constrained('content_elements')->restrictOnDelete();
|
||||
$table->string('source_key', 120);
|
||||
$table->unsignedBigInteger('actor_id')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['film_element_id', 'source_key']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('film_still_sources');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Etappe 1 (Testkauf): nur ergänzend, keine Daten werden gelöscht oder umbenannt.
|
||||
*
|
||||
* - Ein Angebot (Lizenzoption) kann auf die Komposition zeigen, deren öffentliche Seite die Produktseite ist
|
||||
* (`offers.composition_id`). Angebote derselben Komposition bilden die Angebotsgruppe (Alternativen).
|
||||
* - Mitgliedschaft eines Kontos in einer Organisation mit Bestellberechtigung (Domänenmodell 04, MEMBERSHIP).
|
||||
* - Der Erwerb hält das auslösende Konto, die Bestellung Gesamtsumme und Währung, die Position Inhaber, Währung,
|
||||
* Steuerklasse und Vergabeart als Kopie. `orders.party_id` ist der Lizenzinhaber, `orders.user_id` das handelnde Konto.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('offers', function (Blueprint $table) {
|
||||
$table->foreignId('composition_id')->nullable()->constrained('compositions')->nullOnDelete();
|
||||
$table->string('option_label')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('memberships', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('party_id')->constrained()->restrictOnDelete();
|
||||
$table->string('role')->default('mitglied');
|
||||
$table->boolean('may_order')->default(false);
|
||||
$table->date('valid_from')->nullable();
|
||||
$table->date('valid_until')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'party_id']);
|
||||
});
|
||||
|
||||
Schema::table('acquisitions', function (Blueprint $table) {
|
||||
$table->foreignId('acting_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->unsignedInteger('total_cents')->nullable();
|
||||
$table->string('currency', 3)->default('EUR');
|
||||
});
|
||||
|
||||
Schema::table('order_lines', function (Blueprint $table) {
|
||||
$table->string('currency', 3)->default('EUR');
|
||||
$table->string('tax_class')->nullable();
|
||||
$table->string('grant_kind')->nullable();
|
||||
$table->foreignId('holder_party_id')->nullable()->constrained('parties')->restrictOnDelete();
|
||||
});
|
||||
|
||||
// Bestehende Bestellungen: Summe und Inhaber der Position aus den vorhandenen Angaben.
|
||||
foreach (DB::table('orders')->get() as $order) {
|
||||
DB::table('orders')->where('id', $order->id)->update([
|
||||
'total_cents' => (int) DB::table('order_lines')->where('order_id', $order->id)->sum('price_cents'),
|
||||
]);
|
||||
DB::table('order_lines')->where('order_id', $order->id)->update(['holder_party_id' => $order->party_id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('order_lines', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('holder_party_id');
|
||||
$table->dropColumn(['currency', 'tax_class', 'grant_kind']);
|
||||
});
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->dropColumn(['total_cents', 'currency']);
|
||||
});
|
||||
Schema::table('acquisitions', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('acting_user_id');
|
||||
});
|
||||
Schema::dropIfExists('memberships');
|
||||
Schema::table('offers', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('composition_id');
|
||||
$table->dropColumn('option_label');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* „Medium löschen“ (Medien ohne Fassung) muss auch Standbilder aus Filmen und übernommene CMS-Bilder erreichen.
|
||||
*
|
||||
* - film_still_sources: Die Herkunftszeile eines gelöschten Standbilds entfällt (cascade); dieselbe Stelle kann neu
|
||||
* übernommen werden.
|
||||
* - website_media_aliases: Die Zuordnung bleibt als Sperre bestehen (content_element_id wird leer). Ein früherer Pfad
|
||||
* mit gelöschtem Medium wird nicht wieder über /medien/cms/… ausgeliefert und nicht mehr als Bild gezeigt.
|
||||
*
|
||||
* Lockert nur Fremdschlüssel; bestehende Daten bleiben unverändert (rückwärtskompatibel).
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('film_still_sources', function (Blueprint $table) {
|
||||
$table->dropForeign(['still_element_id']);
|
||||
});
|
||||
Schema::table('film_still_sources', function (Blueprint $table) {
|
||||
$table->foreign('still_element_id')->references('id')->on('content_elements')->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('website_media_aliases', function (Blueprint $table) {
|
||||
$table->dropForeign(['content_element_id']);
|
||||
});
|
||||
Schema::table('website_media_aliases', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('content_element_id')->nullable()->change();
|
||||
});
|
||||
Schema::table('website_media_aliases', function (Blueprint $table) {
|
||||
$table->foreign('content_element_id')->references('id')->on('content_elements')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Bewusst leer: Die gelockerten Fremdschlüssel schaden älterem Code nicht, und leere Zuordnungen
|
||||
// (gelöschte Medien) ließen sich nicht in den strengeren Zustand zurückführen.
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Herkunft der Bild-Medien, die aus dem Vorschaubild eines Programms oder Moduls übernommen wurden
|
||||
* (Programm- und Modulkarte). Additiv. Verhindert, dass dasselbe Vorschaubild mehrfach als neues Medium entsteht.
|
||||
* Das übernommene Bild ist ein gewöhnliches Medium (output_class bild) mit eigener Website-Freigabe.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('composition_still_sources', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('composition_id')->constrained('compositions')->cascadeOnDelete();
|
||||
$table->foreignId('still_element_id')->constrained('content_elements')->cascadeOnDelete();
|
||||
$table->string('source_key', 120);
|
||||
$table->unsignedBigInteger('actor_id')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['composition_id', 'source_key']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('composition_still_sources');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Identity\AccountStatus;
|
||||
use App\Domain\Identity\Membership;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Domain\Identity\PartyType;
|
||||
use App\Domain\Identity\RegisterAccount;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Testdaten für den Testkauf (Etappe 1): zwei Programme mit Film und Begleitmaterial, ein Starterpaket, die
|
||||
* Lizenzoptionen für Privatpersonen und für einen Verein, ein Testverein mit bestellberechtigtem Konto und drei
|
||||
* Testkonten. Nur für Entwicklung und die Testinstanz; in Produktion läuft der Seeder nicht.
|
||||
* Mehrfach ausführbar: Vorhandenes bleibt unverändert.
|
||||
*/
|
||||
class ShopDemoSeeder extends Seeder
|
||||
{
|
||||
/** Nur für automatisierte Tests. Außerhalb von Tests gilt LUF_DEMO_PASSWORD oder ein zufälliges Passwort. */
|
||||
public const PASSWORD = 'testkauf-passwort-1';
|
||||
|
||||
private ?string $password = null;
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
if (app()->isProduction() || LicenseArticle::query()->where('code', 'shop-konflikte')->exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = app(ContentService::class);
|
||||
$articles = app(ArticleService::class);
|
||||
$bundles = app(BundleService::class);
|
||||
$offers = app(OfferService::class);
|
||||
$this->password = app()->runningUnitTests()
|
||||
? self::PASSWORD
|
||||
: (getenv('LUF_DEMO_PASSWORD') ?: Str::random(24));
|
||||
$editor = $this->account('Demo Redaktion', 'shop-demo-redaktion@example.test');
|
||||
|
||||
[$konflikteVersion, $konflikteArticle] = $this->program(
|
||||
$content, $articles, $editor, 'shop-konflikte', 'Konflikte im Training',
|
||||
'Wie Trainerinnen und Trainer Konflikte in der Gruppe ruhig und klar begleiten.',
|
||||
'Ein Film, ein Arbeitsblatt und eine Anleitung für sechs Trainingseinheiten.',
|
||||
'Konflikte erkennen, benennen und gemeinsam lösen.',
|
||||
);
|
||||
[$grenzenVersion, $grenzenArticle] = $this->program(
|
||||
$content, $articles, $editor, 'shop-grenzen', 'Grenzen setzen im Verein',
|
||||
'Sicher auftreten, Grenzen vermitteln und Kinder stärken.',
|
||||
'Film und Begleitmaterial für einen Übungsabend zu Grenzen und Respekt.',
|
||||
'Grenzen verständlich vermitteln.',
|
||||
);
|
||||
[$starterVersion, $starterArticle] = $this->program(
|
||||
$content, $articles, $editor, 'shop-starter', 'Starterpaket für neue Trainer',
|
||||
'Das Einstiegspaket mit beiden Programmen und einer Einführung für neue Trainerinnen und Trainer.',
|
||||
'Zusätzlich zu beiden Programmen enthält das Paket eine Einführung ins Konzept.',
|
||||
'Das Konzept kennenlernen.',
|
||||
);
|
||||
|
||||
$privat = $offers->createRightsProfile('Privatlizenz ehrenamtlich', 'ehrenamtlich', [
|
||||
'film' => ['streamen', 'laden'],
|
||||
'pdf' => ['ansehen', 'laden'],
|
||||
]);
|
||||
$verein = $offers->createRightsProfile('Vereinslizenz institutionell', 'institutionell', [
|
||||
'film' => ['streamen', 'laden'],
|
||||
'pdf' => ['ansehen', 'laden'],
|
||||
]);
|
||||
|
||||
$this->offer($offers, 'Konflikte im Training: Privatlizenz', 'Privatlizenz', $konflikteVersion, [$konflikteArticle, $privat], 4900, 'person');
|
||||
$this->offer($offers, 'Konflikte im Training: Vereinslizenz', 'Mehrfachlizenz für Vereine', $konflikteVersion, [$konflikteArticle, $verein], 14900, 'organisation');
|
||||
$this->offer($offers, 'Grenzen setzen: Privatlizenz', 'Privatlizenz', $grenzenVersion, [$grenzenArticle, $privat], 2900, 'person');
|
||||
|
||||
$bundle = $bundles->create('Starterpaket');
|
||||
$starter = $bundles->publish($bundle, [$konflikteArticle->fresh(), $grenzenArticle->fresh(), $starterArticle->fresh()]);
|
||||
$paket = $offers->create('Starterpaket: Privatlizenz');
|
||||
$offers->activate($paket, [['target' => $starter, 'rights' => $privat]], ['grant_kind' => 'kauf', 'price_cents' => 5900, 'holder_kind' => 'person']);
|
||||
$offers->assignProduct($paket, $starterVersion->composition_id, 'Starterpaket (zwei Programme und Einführung)');
|
||||
|
||||
$tina = $this->account('Tina Trainerin', 'tina.trainerin@example.test');
|
||||
$vera = $this->account('Vera Vorstand', 'vera.vorstand@example.test');
|
||||
$max = $this->account('Max Mitglied', 'max.mitglied@example.test');
|
||||
$club = Party::query()->firstOrCreate(
|
||||
['type' => PartyType::Organisation, 'display_name' => 'Testverein Musterstadt e. V.'],
|
||||
);
|
||||
Membership::query()->firstOrCreate(['user_id' => $vera->id, 'party_id' => $club->id], ['role' => 'org_admin', 'may_order' => true]);
|
||||
Membership::query()->firstOrCreate(['user_id' => $max->id, 'party_id' => $club->id], ['role' => 'mitglied', 'may_order' => false]);
|
||||
unset($tina);
|
||||
|
||||
if (! app()->runningUnitTests()) {
|
||||
$this->command?->info('Testkonten angelegt (tina.trainerin, vera.vorstand, max.mitglied und shop-demo-redaktion bei example.test). Passwort: '.($this->password));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwei Dateien (Film, Begleitmaterial) als Platzhalter im Speicher, ein Programm als Komposition mit
|
||||
* Anzeigefreigabe und ein Lizenzartikel dazu.
|
||||
*
|
||||
* @return array{0: CompositionVersion, 1: LicenseArticle}
|
||||
*/
|
||||
private function program(
|
||||
ContentService $content,
|
||||
ArticleService $articles,
|
||||
User $editor,
|
||||
string $code,
|
||||
string $title,
|
||||
string $teaser,
|
||||
string $summary,
|
||||
string $goal,
|
||||
): array {
|
||||
$disk = Storage::disk('media_derived');
|
||||
$disk->put('inhalte/'.$code.'/film.mp4', 'Platzhalter für den Film '.$title);
|
||||
$disk->put('inhalte/'.$code.'/begleitmaterial.pdf', "%PDF-1.4\n% Platzhalter für das Begleitmaterial ".$title."\n%%EOF\n");
|
||||
|
||||
$film = $content->publishElementVersion(
|
||||
$content->createElement('film', 'film', 'Film '.$title),
|
||||
null,
|
||||
['file' => 'inhalte/'.$code.'/film.mp4'],
|
||||
);
|
||||
$sheet = $content->publishElementVersion(
|
||||
$content->createElement('pdf', 'pdf', 'Begleitmaterial '.$title),
|
||||
null,
|
||||
['file' => 'inhalte/'.$code.'/begleitmaterial.pdf'],
|
||||
);
|
||||
$composition = $content->createComposition($title);
|
||||
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||
$composition->display_title = $title;
|
||||
$composition->teaser = $teaser;
|
||||
$composition->summary = $summary;
|
||||
$composition->save();
|
||||
$version = $content->publishComposition(
|
||||
$composition,
|
||||
[['role' => 'Film', 'target' => $film], ['role' => 'Begleitmaterial', 'target' => $sheet]],
|
||||
null,
|
||||
null,
|
||||
['learning_goal' => $goal],
|
||||
);
|
||||
app(CompositionDisplayRelease::class)->release($version, $editor);
|
||||
|
||||
$article = $articles->create($code, 'Testkauf');
|
||||
$article->working_title = $title;
|
||||
$article->display_title = $title;
|
||||
$article->save();
|
||||
$articles->publishRelease($article, $version, 'Programm für den Testkauf.');
|
||||
|
||||
return [$version, $article->fresh()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{0: LicenseArticle, 1: RightsProfileVersion} $line
|
||||
*/
|
||||
private function offer(OfferService $offers, string $name, string $label, CompositionVersion $version, array $line, int $cents, string $holder): Offer
|
||||
{
|
||||
$offer = $offers->create($name);
|
||||
$offers->activate($offer, [['target' => $line[0], 'rights' => $line[1]]], [
|
||||
'grant_kind' => 'kauf',
|
||||
'price_cents' => $cents,
|
||||
'holder_kind' => $holder,
|
||||
]);
|
||||
$offers->assignProduct($offer, $version->composition_id, $label);
|
||||
|
||||
return $offer;
|
||||
}
|
||||
|
||||
private function account(string $name, string $email): User
|
||||
{
|
||||
$existing = User::query()->where('email', $email)->first();
|
||||
|
||||
if ($existing !== null) {
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$user = app(RegisterAccount::class)->register($name, $email, (string) $this->password, true);
|
||||
$user->forceFill(['email_verified_at' => now(), 'status' => AccountStatus::Aktiv])->save();
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/* Lara & Felix – draft brand tokens; source imagery sampled 2026-11-15.
|
||||
Do not treat these color values or fonts as final without approval. */
|
||||
:root {
|
||||
--lf-navy: #032551;
|
||||
--lf-navy-deep: #01244C;
|
||||
--lf-green: #5B8625;
|
||||
--lf-green-deep: #3B7B09;
|
||||
--lf-yellow: #FCD10A;
|
||||
--lf-cream: #F7F6F2;
|
||||
--lf-white: #FFFFFF;
|
||||
--lf-surface: #F9FAF7;
|
||||
--lf-ink: #15243A;
|
||||
--lf-muted: #5D6A78;
|
||||
--lf-border: #DDE5E3;
|
||||
--lf-focus: #1769AA;
|
||||
--lf-error: #B92F38;
|
||||
--lf-radius-sm: 8px;
|
||||
--lf-radius-md: 14px;
|
||||
--lf-radius-lg: 22px;
|
||||
--lf-radius-pill: 999px;
|
||||
--lf-shadow-card: 0 12px 30px rgb(3 37 81 / .07);
|
||||
--lf-max-container: 1180px;
|
||||
--lf-font-ui: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
|
||||
--lf-font-display: "Nunito", "Trebuchet MS", system-ui, sans-serif;
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
{
|
||||
"$schema": "https://design-tokens.github.io/community-group/format/",
|
||||
"status": "working draft, needs formal brand approval",
|
||||
"source": "sampled colors from uploaded title/denkpause, with supporting UI tokens chosen for accessibility",
|
||||
"color": {
|
||||
"navy": {
|
||||
"$type": "color",
|
||||
"$value": "#032551"
|
||||
},
|
||||
"navy_deep": {
|
||||
"$type": "color",
|
||||
"$value": "#01244C"
|
||||
},
|
||||
"green": {
|
||||
"$type": "color",
|
||||
"$value": "#5B8625"
|
||||
},
|
||||
"green_deep": {
|
||||
"$type": "color",
|
||||
"$value": "#3B7B09"
|
||||
},
|
||||
"yellow": {
|
||||
"$type": "color",
|
||||
"$value": "#FCD10A"
|
||||
},
|
||||
"cream": {
|
||||
"$type": "color",
|
||||
"$value": "#F7F6F2"
|
||||
},
|
||||
"white": {
|
||||
"$type": "color",
|
||||
"$value": "#FFFFFF"
|
||||
},
|
||||
"surface": {
|
||||
"$type": "color",
|
||||
"$value": "#F9FAF7"
|
||||
},
|
||||
"ink": {
|
||||
"$type": "color",
|
||||
"$value": "#15243A"
|
||||
},
|
||||
"muted": {
|
||||
"$type": "color",
|
||||
"$value": "#5D6A78"
|
||||
},
|
||||
"border": {
|
||||
"$type": "color",
|
||||
"$value": "#DDE5E3"
|
||||
},
|
||||
"focus": {
|
||||
"$type": "color",
|
||||
"$value": "#1769AA"
|
||||
},
|
||||
"error": {
|
||||
"$type": "color",
|
||||
"$value": "#B92F38"
|
||||
}
|
||||
},
|
||||
"radius": {
|
||||
"sm": {
|
||||
"$type": "dimension",
|
||||
"$value": "8px"
|
||||
},
|
||||
"md": {
|
||||
"$type": "dimension",
|
||||
"$value": "14px"
|
||||
},
|
||||
"lg": {
|
||||
"$type": "dimension",
|
||||
"$value": "22px"
|
||||
},
|
||||
"pill": {
|
||||
"$type": "dimension",
|
||||
"$value": "999px"
|
||||
}
|
||||
},
|
||||
"space": {
|
||||
"1": {
|
||||
"$type": "dimension",
|
||||
"$value": "4px"
|
||||
},
|
||||
"2": {
|
||||
"$type": "dimension",
|
||||
"$value": "8px"
|
||||
},
|
||||
"3": {
|
||||
"$type": "dimension",
|
||||
"$value": "12px"
|
||||
},
|
||||
"4": {
|
||||
"$type": "dimension",
|
||||
"$value": "16px"
|
||||
},
|
||||
"5": {
|
||||
"$type": "dimension",
|
||||
"$value": "20px"
|
||||
},
|
||||
"6": {
|
||||
"$type": "dimension",
|
||||
"$value": "24px"
|
||||
},
|
||||
"7": {
|
||||
"$type": "dimension",
|
||||
"$value": "28px"
|
||||
},
|
||||
"8": {
|
||||
"$type": "dimension",
|
||||
"$value": "32px"
|
||||
},
|
||||
"9": {
|
||||
"$type": "dimension",
|
||||
"$value": "36px"
|
||||
},
|
||||
"10": {
|
||||
"$type": "dimension",
|
||||
"$value": "40px"
|
||||
},
|
||||
"11": {
|
||||
"$type": "dimension",
|
||||
"$value": "44px"
|
||||
},
|
||||
"12": {
|
||||
"$type": "dimension",
|
||||
"$value": "48px"
|
||||
},
|
||||
"13": {
|
||||
"$type": "dimension",
|
||||
"$value": "52px"
|
||||
},
|
||||
"14": {
|
||||
"$type": "dimension",
|
||||
"$value": "56px"
|
||||
},
|
||||
"15": {
|
||||
"$type": "dimension",
|
||||
"$value": "60px"
|
||||
},
|
||||
"16": {
|
||||
"$type": "dimension",
|
||||
"$value": "64px"
|
||||
}
|
||||
},
|
||||
"typography": {
|
||||
"display": "Rounded friendly display – select licensed font",
|
||||
"body": "Highly readable sans – select licensed font"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="17" fill="#032551"/><path d="M10 45V17h8v20h12v8z" fill="#fff"/><text x="31" y="42" font-family="system-ui,sans-serif" font-size="19" font-weight="900" fill="white">F</text><path d="M9 53Q28 43 55 49" stroke="#FCD10A" stroke-width="5" fill="none" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 370 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><g fill="none" stroke="#032551" stroke-width="5" stroke-linejoin="round" stroke-linecap="round"><path d="M20 53V30c0-9 13-9 13 0V16c0-9 13-9 13 0v11-17c0-9 13-9 13 0v18-14c0-9 13-9 13 0v36l7-10c7-9 20-3 15 7L76 82C67 93 43 94 30 86L9 64C2 56 13 47 20 53z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 329 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 258"><path d="M59 68C72 19 132 6 165 35c39-37 103-10 113 30 56-3 78 45 56 86 10 45-42 89-95 75-39 30-94 12-109-11-38 21-100-11-99-56-27-29-20-78 28-91z" fill="#FFFFFF" stroke="#032551" stroke-width="7" stroke-linejoin="round"/><circle cx="48" cy="233" r="14" fill="white" stroke="#032551" stroke-width="6"/><circle cx="17" cy="253" r="6" fill="white" stroke="#032551" stroke-width="4"/></svg>
|
||||
|
After Width: | Height: | Size: 449 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 85"><g fill="none" stroke="#FCD10A" stroke-linecap="round" stroke-width="11"><path d="M23 52L6 40"/><path d="M48 29L46 9"/><path d="M74 44L89 23"/></g></svg>
|
||||
|
After Width: | Height: | Size: 214 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 28"><path d="M9 18 Q102 1 270 12" fill="none" stroke="#FCD10A" stroke-width="13" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 168 B |
@@ -0,0 +1,13 @@
|
||||
# Cursor-Übergabe: Brand & UI Kit
|
||||
|
||||
**Noch nicht umsetzen, bevor der funktionale MVP praktisch überprüft und korrigiert wurde.**
|
||||
|
||||
1. Lies `docs/prinzipien/design-prinzipien.md` und `docs/prinzipien/seo-und-content-prinzipien.md` sowie `CLAUDE.md`.
|
||||
2. Nutze das Brand & UI Kit v1.0 als **Entwurfs- und Vergleichsmaterial**, nicht als unhinterfragte, finale Markenfreigabe.
|
||||
3. Inventarisiere zuerst den tatsächlichen Stand des bestehenden Laravel/Filament-Frontends und der Originalmedien.
|
||||
4. Mache mit den originalen Lara-&-Felix-Assets und einem ruhigen Erwachsenen-UI-Design konkrete Layoutvarianten. Die Denkpause wird gezielt didaktisch eingesetzt.
|
||||
5. Übernehme nur explizit freigegebene Logo-, Typografie- und Farbvarianten. Markenfarben im Kit sind abgeleitete Vorschläge.
|
||||
6. Bewahre die fachlich bestehende CMS-/Katalog-/Lizenzstruktur. Die statischen HTML-Screens sind keine technische Architekturvorgabe.
|
||||
7. Alle öffentlichen Produkt- und SEO-Texte kommen aus dem echten Katalog/CMS; keine Demo-Preise, keine KI-erfundenen Filme, keine erfundenen Wirkungsversprechen.
|
||||
8. Validierung: Screenshots in 390/768/1440 px, Tastatur, Kontrast, Reduced Motion, LCP/CLS, Auth-/Berechtigungsregressionen.
|
||||
9. Kein Produktionsdeployment ohne die in `CLAUDE.md` vorgesehene Freigabe.
|
||||
@@ -0,0 +1,386 @@
|
||||
\# Lara \& Felix – Verbindliche Design- und UX-Anforderungen
|
||||
|
||||
|
||||
|
||||
\## 1. Designqualität ist ein gleichrangiges Projektziel
|
||||
|
||||
|
||||
|
||||
Die Benutzeroberfläche von Lara \& Felix muss gestalterisch, funktional und technisch dem Niveau einer hochwertigen, professionell entwickelten digitalen Plattform entsprechen.
|
||||
|
||||
|
||||
|
||||
\*\*Ein gewöhnliches, erkennbar KI-generiertes Standardtemplate ist ausdrücklich nicht akzeptabel.\*\*
|
||||
|
||||
|
||||
|
||||
Die Plattform muss eine eigenständige visuelle Identität besitzen, die konsistent über Marketing-Webseite, Anmeldung, Mitgliederbereich, Katalog, Bibliothek und Kursplayer umgesetzt wird.
|
||||
|
||||
|
||||
|
||||
Designqualität ist ein verbindliches Abnahmekriterium und darf nicht zugunsten einer schnelleren rein funktionalen Implementierung entfallen.
|
||||
|
||||
|
||||
|
||||
\## 2. Gestalterische Richtung
|
||||
|
||||
|
||||
|
||||
Entwickle ein zeitgemäßes Premium-Design mit folgenden Eigenschaften:
|
||||
|
||||
|
||||
|
||||
\- Eigenständige, wiedererkennbare Markenidentität
|
||||
|
||||
\- Hochwertige Editorial-Typografie mit differenzierter Schriftgrößenhierarchie
|
||||
|
||||
\- Bewusst gestaltete, teilweise asymmetrische Layouts
|
||||
|
||||
\- Großzügige, aber funktional eingesetzte Weißräume
|
||||
|
||||
\- Präzise abgestimmte Farben und Kontraste
|
||||
|
||||
\- Hochwertige Bild- und Videointegration
|
||||
|
||||
\- Professionelle, dezente Mikroanimationen
|
||||
|
||||
\- Ausgefeilte Hover-, Fokus-, Lade- und Übergangszustände
|
||||
|
||||
\- Konsistentes Erscheinungsbild über alle Bereiche
|
||||
|
||||
\- Sehr gute Bedienbarkeit auf Smartphone, Tablet und Desktop
|
||||
|
||||
|
||||
|
||||
Die Bildsprache soll selbstbewusst, freundlich, vertrauenswürdig und authentisch sein.
|
||||
|
||||
|
||||
|
||||
Die Plattform richtet sich an erwachsene Trainer und pädagogische Fachkräfte. Das Design darf modern und emotional sein, soll aber nicht kindlich, verspielt oder sensationsorientiert wirken.
|
||||
|
||||
|
||||
|
||||
Gewaltprävention ist ein ernsthaftes Bildungsthema. Vermeide dramatisierende Darstellungen von Gewalt oder Angst.
|
||||
|
||||
|
||||
|
||||
\## 3. Austauschbares KI-Design ausdrücklich vermeiden
|
||||
|
||||
|
||||
|
||||
Vermeide insbesondere:
|
||||
|
||||
|
||||
|
||||
\- Beliebige Blau-Violett-Verläufe als dominantes Standardmotiv
|
||||
|
||||
\- Austauschbare Hero-Sektionen mit generischen Marketingfloskeln
|
||||
|
||||
\- Endlose Reihen identischer abgerundeter Karten
|
||||
|
||||
\- Beliebige Stockfotos ohne inhaltlichen Bezug
|
||||
|
||||
\- Dekorative Glaseffekte ohne funktionalen Nutzen
|
||||
|
||||
\- Übertriebene Schatten und Leuchteffekte
|
||||
|
||||
\- Belanglose, inflationär eingesetzte Icons
|
||||
|
||||
\- Unnötige Animationen, die die Nutzung verlangsamen
|
||||
|
||||
\- Generische SaaS-Dashboards ohne Bezug zum Lern- und Trainingskontext
|
||||
|
||||
\- Einheitliche Standardlayouts auf jeder Seite
|
||||
|
||||
|
||||
|
||||
Wichtig: Diese Stilmittel sind nicht grundsätzlich verboten. Sie sollen nur eingesetzt werden, wenn sie eine nachvollziehbare gestalterische Funktion erfüllen.
|
||||
|
||||
|
||||
|
||||
\*\*Bevorzuge eine bewusst komponierte und differenzierte Gestaltung gegenüber einer Aneinanderreihung vorgefertigter UI-Komponenten.\*\*
|
||||
|
||||
|
||||
|
||||
\## 4. Professionelles Designsystem
|
||||
|
||||
|
||||
|
||||
Lege früh ein wiederverwendbares Designsystem an.
|
||||
|
||||
|
||||
|
||||
Es soll enthalten:
|
||||
|
||||
|
||||
|
||||
\- Farbpalette mit semantischen Design-Tokens
|
||||
|
||||
\- Typografiesystem
|
||||
|
||||
\- Abstands- und Rastersystem
|
||||
|
||||
\- Responsive Layoutregeln
|
||||
|
||||
\- Schaltflächen und Links
|
||||
|
||||
\- Formulare und Eingabefelder
|
||||
|
||||
\- Navigationselemente
|
||||
|
||||
\- Karten, Listen und Inhaltsvorschauen
|
||||
|
||||
\- Statusanzeigen und Rückmeldungen
|
||||
|
||||
\- Modale Dialoge
|
||||
|
||||
\- Lade-, Leer- und Fehlerzustände
|
||||
|
||||
\- Animationen und Übergänge
|
||||
|
||||
|
||||
|
||||
Dieses Designsystem gilt für die öffentliche Webseite und den Mitgliederbereich.
|
||||
|
||||
|
||||
|
||||
Die interne Filament-Administration darf funktionaler gestaltet sein, soll aber eine saubere und konsistente Bedienung aufweisen.
|
||||
|
||||
|
||||
|
||||
Nutze bestehende Komponentenbibliotheken, wo sie helfen. Die sichtbare Produktoberfläche darf dennoch nicht wie eine unveränderte Komponentenbibliothek aussehen.
|
||||
|
||||
|
||||
|
||||
\## 5. Marketing-Webseite
|
||||
|
||||
|
||||
|
||||
Die öffentliche Startseite soll wie der Auftritt einer eigenständigen, hochwertigen Bildungsmarke wirken.
|
||||
|
||||
|
||||
|
||||
Besondere Aufmerksamkeit verdienen:
|
||||
|
||||
|
||||
|
||||
\- Der erste sichtbare Bildschirmbereich
|
||||
|
||||
\- Die visuelle Einführung in das Konzept
|
||||
|
||||
\- Die Präsentation von Filmen und Materialien
|
||||
|
||||
\- Die Erklärung des didaktischen Ansatzes
|
||||
|
||||
\- Die Darstellung von Zielgruppen
|
||||
|
||||
\- Übersichtliche Handlungsaufrufe
|
||||
|
||||
\- Der Übergang zur Anmeldung beziehungsweise zum Mitgliederbereich
|
||||
|
||||
|
||||
|
||||
Nutze die tatsächlich vorhandenen Lara-\&-Felix-Filme und ihre Bildwelt als Grundlage für die spätere Markenkommunikation, sofern passende freigegebene Assets verfügbar sind.
|
||||
|
||||
|
||||
|
||||
Keine erfundenen Kundenbewertungen, Partnerlogos, Qualifikationen oder Wirkungsversprechen.
|
||||
|
||||
|
||||
|
||||
\## 6. Mitgliederbereich
|
||||
|
||||
|
||||
|
||||
Der Mitgliederbereich muss sich wie ein eigenständiges, hochwertiges digitales Produkt anfühlen.
|
||||
|
||||
|
||||
|
||||
Die Oberfläche soll:
|
||||
|
||||
|
||||
|
||||
\- Eine besonders übersichtliche Bibliothek bieten
|
||||
|
||||
\- Filme, Übungen und Materialien visuell klar unterscheiden
|
||||
|
||||
\- Unterschiedliche Inhaltsarten und Pakete verständlich darstellen
|
||||
|
||||
\- Berechtigungen nachvollziehbar anzeigen
|
||||
|
||||
\- Eine ausgezeichnete Suche und Orientierung ermöglichen
|
||||
|
||||
\- Auch bei umfangreichen Inhaltsbeständen übersichtlich bleiben
|
||||
|
||||
\- Einen besonders sorgfältig gestalteten Kursplayer besitzen
|
||||
|
||||
|
||||
|
||||
Der Mitgliederbereich darf nicht einfach eine umbenannte Filament-Administrationsoberfläche sein.
|
||||
|
||||
|
||||
|
||||
\## 7. Interaktionen und Feinschliff
|
||||
|
||||
|
||||
|
||||
Implementiere durchdachte Mikrointeraktionen und visuelle Rückmeldungen.
|
||||
|
||||
|
||||
|
||||
Dazu gehören beispielsweise:
|
||||
|
||||
|
||||
|
||||
\- Konsistente Hover- und Fokuszustände
|
||||
|
||||
\- Sanfte, gezielte Übergänge
|
||||
|
||||
\- Verständliche Ladezustände
|
||||
|
||||
\- Hochwertige leere Bibliotheksansichten
|
||||
|
||||
\- Klare Erfolgsmeldungen und Fehlermeldungen
|
||||
|
||||
\- Sinnvolle Tastaturinteraktionen
|
||||
|
||||
\- Gute Formularvalidierung
|
||||
|
||||
\- Keine unnötigen Layoutsprünge
|
||||
|
||||
|
||||
|
||||
Animationen müssen bei aktivierter Einstellung `prefers-reduced-motion` entsprechend reduziert werden.
|
||||
|
||||
|
||||
|
||||
\## 8. Zugänglichkeit und Performance
|
||||
|
||||
|
||||
|
||||
Gestalterische Qualität darf nicht auf Kosten der Zugänglichkeit oder Geschwindigkeit entstehen.
|
||||
|
||||
|
||||
|
||||
Richte dich nach WCAG 2.2 AA.
|
||||
|
||||
|
||||
|
||||
Prüfe insbesondere:
|
||||
|
||||
|
||||
|
||||
\- Kontraste
|
||||
|
||||
\- Tastaturbedienbarkeit
|
||||
|
||||
\- Sichtbare Fokuszustände
|
||||
|
||||
\- Semantische Struktur
|
||||
|
||||
\- Verständliche Formulare
|
||||
|
||||
\- Responsives Verhalten
|
||||
|
||||
\- Untertitel und Bedienelemente des Players
|
||||
|
||||
|
||||
|
||||
Orientiere dich bei der Performance an den Core Web Vitals.
|
||||
|
||||
|
||||
|
||||
Optimiere große Bilder und Videos, vermeide unnötiges JavaScript und achte auf stabile Layouts.
|
||||
|
||||
|
||||
|
||||
\## 9. Verbindliche visuelle Qualitätssicherung
|
||||
|
||||
|
||||
|
||||
\*\*Technisch erfolgreiche Tests allein reichen für den Abschluss einer Benutzeroberfläche nicht aus.\*\*
|
||||
|
||||
|
||||
|
||||
Führe nach der Implementierung jedes wesentlichen Bildschirmbereichs eine visuelle Kontrolle durch.
|
||||
|
||||
|
||||
|
||||
Prüfe mindestens:
|
||||
|
||||
|
||||
|
||||
\- Desktop bei etwa 1440 Pixeln Breite
|
||||
|
||||
\- Tablet bei etwa 768 Pixeln Breite
|
||||
|
||||
\- Smartphone bei etwa 390 Pixeln Breite
|
||||
|
||||
|
||||
|
||||
Kontrolliere gerenderte Screenshots beziehungsweise die tatsächliche Browserdarstellung, soweit die Entwicklungsumgebung dies ermöglicht.
|
||||
|
||||
|
||||
|
||||
Achte auf:
|
||||
|
||||
|
||||
|
||||
\- Typografische Qualität
|
||||
|
||||
\- Ausgewogene Layouts
|
||||
|
||||
\- Lesbarkeit
|
||||
|
||||
\- Konsistente Abstände
|
||||
|
||||
\- Bildzuschnitte
|
||||
|
||||
\- Navigationsverhalten
|
||||
|
||||
\- Interaktionszustände
|
||||
|
||||
\- Visuelle Hierarchie
|
||||
|
||||
\- Responsives Verhalten
|
||||
|
||||
|
||||
|
||||
Beseitige erkennbare gestalterische Schwächen eigenständig.
|
||||
|
||||
|
||||
|
||||
Behaupte keine visuelle Prüfung, wenn die Seite nicht tatsächlich gerendert und betrachtet wurde.
|
||||
|
||||
|
||||
|
||||
\## 10. Umsetzung ohne zusätzliche Planungs-Gates
|
||||
|
||||
|
||||
|
||||
Erarbeite vor der Gestaltung ein kompaktes visuelles Konzept und ein Designsystem.
|
||||
|
||||
|
||||
|
||||
Setze dieses anschließend unmittelbar in der Anwendung um.
|
||||
|
||||
|
||||
|
||||
\*\*Kein zusätzlicher Freigabe-Stopp für reine Designkonzepte.\*\*
|
||||
|
||||
|
||||
|
||||
Die erste fachliche Abnahme erfolgt anhand der tatsächlich implementierten Marketing-Webseite und des Mitgliederbereichs.
|
||||
|
||||
|
||||
|
||||
Überarbeite die Oberflächen eigenständig, bis sowohl die funktionalen als auch die gestalterischen Qualitätsziele erfüllt sind.
|
||||
|
||||
|
||||
|
||||
Ein optisch generisches, offensichtlich unfertiges Frontend erfüllt den Entwicklungsauftrag nicht.
|
||||
|
||||
|
||||
|
||||
\*\*Ziel ist eine individuelle, hochwertige, moderne und langfristig erweiterbare digitale Marke – nicht nur eine funktionierende Laravel-Anwendung.\*\*
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
# Lara & Felix – Webmarke und globaler Header | Designfreigabe-Vorlage v1.1
|
||||
|
||||
**Datum:** 18.11.2026
|
||||
**Status:** Zur fachlichen/visuellen Freigabe vorgeschlagen; keine automatische Markenfreigabe.
|
||||
**Basis:** Brand & UI Kit v1.0, Originalmotive, `design-prinzipien.md`, bestehendes CMS.
|
||||
|
||||
## A. Gesicherter Bestand
|
||||
|
||||
- Die sechs Bilder unter `01_originale/` sind Quellen/Referenzen und unverändert; ihre Freigabe zur öffentlichen Verwendung ist im Quellenmanifest nicht bestätigt.
|
||||
- Die eigentliche Lara-&-Felix-Wortmarke ist in Titel-/Outro-Motiven enthalten, aber **nicht als isolierte, offiziell freigegebene Logo-Datei** vorhanden.
|
||||
- Die SVG-Datei `favicon-monogram-entwurf.svg` ist ausdrücklich **kein** freigegebenes Logo.
|
||||
- `02_design_tokens/` enthält Arbeitswerte, keine formal freigegebene Markenpalette.
|
||||
- Der visuelle Homepage-Entwurf ist eine Gestaltungsreferenz. Der statische HTML-Prototyp ist keine Produktionsarchitektur.
|
||||
|
||||
## B. Weblogo: vorgeschlagene freizugebende Varianten
|
||||
|
||||
**W1 – Primäre farbige Wortmarke**
|
||||
- Originalwirkung der Lara-&-Felix-Wortmarke mit grüner Zeile „Stark im Alltag“ und gezieltem gelbem Akzent erhalten.
|
||||
- Für helle Headerflächen; als sauberes, separat exportiertes Asset, bevorzugt SVG **nur bei originalgetreuer Freigabe**, alternativ hochauflösendes transparentes PNG/WebP.
|
||||
- Keine Neuschöpfung oder freie KI-Nachzeichnung. Im Originalmotiv enthaltene Hintergründe nicht als Logo-Hintergrund mit ausschneiden.
|
||||
|
||||
**W2 – Kompaktvariante für Sticky-/Mobile-Header**
|
||||
- Gleiche Markenidentität, aber kleinere Mindestabmessungen und geprüfte Lesbarkeit.
|
||||
- Vorzug: identische Wortmarke mit korrekten Proportionen. Nur wenn diese in kleinen Größen unlesbar ist, eine gesondert freizugebende vereinfachte Variante.
|
||||
- Kein neues L&F-Monogramm ohne Freigabe.
|
||||
|
||||
**W3 – Negativ-/Footer-Variante**
|
||||
- Auf Navy kontrastreich, markentreu und aus demselben Original abgeleitet; nicht pauschal invertieren, wenn gelbe/grüne Details dadurch verändert werden.
|
||||
|
||||
### Noch zu entscheiden
|
||||
- Gibt es eine separierte Original-Logodatei aus dem Filmprojekt?
|
||||
- Wird die Trennung der Wortmarke aus dem Titelbild als **originalgetreue Asset-Aufbereitung** freigegeben?
|
||||
- Welche Varianten W1/W2/W3 sind nach Sichtprüfung verbindlich?
|
||||
|
||||
## C. Stabiler Header: funktionale Spezifikation
|
||||
|
||||
1. **Ein globaler Header für alle öffentlichen CMS-Seiten**, keine separaten pro-Seite-Header.
|
||||
2. Header-Inhalt orientiert sich an **demselben horizontalen Markenraster auf jeder Seite**; seine Nutzbreite bleibt unabhängig von Seitentitel, Navigationseintrag und Scrollbar stabil.
|
||||
3. **Desktop initial:** sichtbare originale Wortmarke links; CMS-Navigation als mittlere Funktionszone; Konto-/später Warenkorb-Aktionen rechts. Keine ungeplanten Umbrüche der Navigation.
|
||||
4. **Desktop kompakt/sticky:** geringere definierte Höhe; Wortmarke proportional kleiner; Navigation und Aktionen stabil. Zustandswechsel allein scrollabhängig, ohne Layoutsprung des Inhalts; CSS/JS technisch mit reservierter Headerfläche oder vergleichbarem stabilen Mechanismus.
|
||||
5. **Mobil:** kompakter Top-Header mit Wortmarke, Menü und Mitgliedszugang. Öffentlich keine Bottom-Navigation. Hauptmenü als zugängliches Overlay/Drawer.
|
||||
6. **Kein seitenabhängiges „Wackeln“:** identische Logo-x-Position und definierte Headerhöhe je Zustand; aktive Nav-Markierung belegt keinen zusätzlichen Platz und ändert keine Breite.
|
||||
7. **Barrierefreiheit:** Tastatur-/Fokusbedienung, korrekte aria-Zustände, ausreichende Touchflächen, Kontrast, `prefers-reduced-motion`.
|
||||
8. **Browserabnahme:** Wechsel zwischen Start-, Themen-, kurzer und langer Seite bei 390/768/1440/1920 px und Browserzoom 100 %; kontrollierter Scrolltest, Prüfung auf Layoutverschiebungen.
|
||||
|
||||
## D. Globale Seitenbreiten
|
||||
|
||||
- Hintergründe: **Full Bleed** bis zum Fensterrand möglich.
|
||||
- **Breit** für Hero und Editorial-Bilder: vorläufig maximal etwa 1440 px.
|
||||
- **Standard** für gemischte Inhaltsabschnitte: vorläufig etwa 1200 px.
|
||||
- **Lesebereich** für lange Texte: etwa 720–800 px.
|
||||
- Definierte responsive Seitenränder und gemeinsame zentral gepflegte Tokens, nicht pro Seite CSS-Sonderfälle.
|
||||
- Die CMS-Einstellungen „Schmal“, „Standard“, „Breit“, „Vollbreite“ müssen diese Semantik tatsächlich abbilden; keine fixierten Pixeldimensionen für alle Bildschirmgrößen.
|
||||
- Werte sind **Abnahmevorschläge**; Endwerte anhand echter Seite und vorhandener Marke testen.
|
||||
|
||||
## E. Wiederkehrende Markensignaturen
|
||||
|
||||
- Gelbe Unterstreichungen und kurze Signalstrahlen aus `03_svg_entwuerfe/` als **optionale** grafische Mittel; nicht als dekoratives Dauerrauschen.
|
||||
- Grüner Akzent für Themen/CTA nach Kontrastprüfung.
|
||||
- Denkpause-Hand und Denkblase **nur** im passenden didaktischen Kontext.
|
||||
- Keine neuen Pflanzenmotive oder fremde Markenwelt; Originalfiguren nur nach Freigabe.
|
||||
|
||||
## F. Freigabematrix
|
||||
|
||||
| Gegenstand | Status | Nächster Prüfschritt |
|
||||
|---|---|---|
|
||||
| Wortmarke aus Originalmotiven | Quelle vorhanden, isoliertes Asset fehlt | Originalgetreue Extraktion/Export vorführen |
|
||||
| Mobile Kompaktmarke | Konzeptioneller Vorschlag | Visueller Vergleich bei Zielgrößen |
|
||||
| Footer-Negativmarke | Konzeptioneller Vorschlag | Kontrast-/Originaltreue-Test |
|
||||
| Navy/Grün/Gelb/Creme | Token-Entwürfe | Markenfarben explizit abnehmen |
|
||||
| Nunito/Nunito Sans | Schriftvorschläge | Lesbarkeit, Lizenz, lokale Bereitstellung prüfen |
|
||||
| Header normal/kompakt | Funktional beschlossen, Gestaltung offen | Zwei Zustände mit Originalmarke im Browser prüfen |
|
||||
| Seitenbreiten | Semantisches Konzept beschlossen, Zahlen vorläufig | 390/768/1440/1920 px prüfen |
|
||||
| Gelbe Signaturen | SVG-Entwurf | Dosierung und Einsatzbeispiele freigeben |
|
||||
|
||||
## G. Grenzen zur laufenden CMS-Implementierung
|
||||
|
||||
- Die vorhandene Widget-Registry und das Abschnitts-/Slot-Modell bleiben maßgeblich.
|
||||
- Header und Footer sind **globale Layoutkomponenten**, keine frei kopierten CMS-Widgets.
|
||||
- Die öffentliche Seitennavigation bleibt CMS-gesteuert, die Mitgliederbibliothek behält eine eigene fachliche Navigation.
|
||||
- Diese Spezifikation gibt keine öffentlichen Medien, Firmenangaben, Produkte, Lizenzen oder Kurse frei.
|
||||
|
||||
## H. Empfohlene nächste Designabnahme
|
||||
|
||||
**Erst** zwei bis drei echte Headerzustände mit Original- bzw. nachvollziehbar vorläufiger Wortmarke sichtbar machen (Desktop initial, Desktop sticky, Mobil); dabei Logo-Originaltreue, Breitenraster und Stabilität prüfen. Danach Hero- und Karten-Familien im selben Markensystem ausarbeiten. Keine erneute CMS-Architekturarbeit.
|
||||
@@ -0,0 +1,3 @@
|
||||
# Brand & UI Kit – Ergänzung v1.1
|
||||
|
||||
Diese Ergänzung enthält eine **Freigabevorlage** zu Weblogo und globalem Header. Die Originaldateien des v1.0-Kits sind unverändert übernommen. Das Dokument ist kein Nachweis einer formalen Markenfreigabe.
|
||||
@@ -0,0 +1,10 @@
|
||||
# Freigegebene Logo-Gestaltungsrichtung – Stand 18.11.2026
|
||||
|
||||
Die Freigabe im Chat betrifft die zuletzt dargestellte Wortmarken-Gestaltung. Hier liegen zwei **Rastergrößen** derselben Wortmarke: `standard` für großflächige Darstellung und `kompakt` für kleinere Einbindungen. Schriftgestaltung und Layout bleiben unverändert.
|
||||
|
||||
- `logo_lara_felix_standard.png`: volle Auflösung, Bildfassung der freigegebenen Darstellung.
|
||||
- `logo_lara_felix_kompakt.png`: proportional verkleinerte Variante, keine neu gezeichnete Schrift.
|
||||
|
||||
**Technischer Vorbehalt:** Diese Dateien enthalten den ursprünglich generierten **dunklen Hintergrund**. Sie sind keine freigestellten transparenten Logos oder Vektordateien und dürfen nicht als solche bezeichnet werden. Für einen hellen Website-Header ist die freigestellte Fassung weiterhin herzustellen und gesondert visuell zu prüfen. Die beiden Dateien sind verwertbare Original-Referenzbilder für die Design-Umsetzung, nicht bereits finale transparente Weblogos.
|
||||
|
||||
Die SVG-Strahlen und die gelbe Unterstreichung unter `03_svg_entwuerfe/` bleiben eigenständige Grafikressourcen. Keine nachträgliche Neuzeichnung als Logo.
|
||||
|
After Width: | Height: | Size: 344 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1,21 @@
|
||||
# Lara & Felix – Hero-Widget v1.3 (Design-Arbeitsstand)
|
||||
|
||||
## Direkt ansehen
|
||||
`09_hero_widget/preview/index.html` im Browser öffnen. Diese Vorschau ist interaktiv: Titel, Text, Buttontexte, Variante und Bildfokus ändern sich unmittelbar. Die beiden Buttons führen absichtlich nur zu einem Demo-Anker.
|
||||
|
||||
## Enthalten
|
||||
- `assets/lara-felix-park-original.png`: **unverändert übernommene Kling-Datei**, Figuren nicht neu generiert.
|
||||
- `assets/lara-felix-park-hero.webp`: effiziente 1:1-Konvertierung derselben Aufnahme.
|
||||
- `assets/yellow-rays.svg`, `yellow-underline.svg`: unveränderte Entwurfsassets aus dem Brand-Kit.
|
||||
- `components/lf-hero.css`: isolierte responsive Komponente.
|
||||
- `components/widget-contract.json`: vorgeschlagene CMS-Felder/Varianten.
|
||||
- `preview/index.html`: eigenständige HTML-Demo mit veränderbaren Eingaben.
|
||||
|
||||
## CMS-Integration
|
||||
Die vorhandene zentrale Widget-Registry soll die Felder nach `components/widget-contract.json` abbilden. HTML-Preview ist **kein zweiter Editor** und kein Ersatz der bestehenden Blade-Komponente. Text serverseitig escapen; URL-Schema prüfen; nur öffentlich freigegebene Medien als Bildquelle nutzen. Die vorhandene Laravel-/Filament-Speicherung und Medienberechtigungen beibehalten.
|
||||
|
||||
## Freigabestatus
|
||||
**Vorlage/Designvorschlag**, nicht fachlich bzw. produktiv freigegeben. Das Kling-Motiv wurde vom Nutzer bereitgestellt; eine eigenständige öffentliche Asset-Freigabe ist nicht automatisch vorausgesetzt. Demo-Texte und Links sind Platzhalter. Die Figuren wurden beim Bau dieses Pakets nicht verändert.
|
||||
|
||||
## Responsive Verhalten
|
||||
Ab 850px Bild als große Hintergrundfläche, Texte vor hellem Verlauf links. Auf schmalen Screens Bild oberhalb der Textfläche, mit steuerbarer Objektposition; keine über das Bild gerenderte Überschrift.
|
||||
|
After Width: | Height: | Size: 221 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 85"><g fill="none" stroke="#FCD10A" stroke-linecap="round" stroke-width="11"><path d="M23 52L6 40"/><path d="M48 29L46 9"/><path d="M74 44L89 23"/></g></svg>
|
||||
|
After Width: | Height: | Size: 214 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 28"><path d="M9 18 Q102 1 270 12" fill="none" stroke="#FCD10A" stroke-width="13" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 168 B |
@@ -0,0 +1,9 @@
|
||||
/* Lara & Felix brand hero v1.3: standalone CSS, scoped to lf-hero. */
|
||||
.lf-hero{--lf-navy:#032551;--lf-green:#3B7B09;--lf-yellow:#FCD10A;--lf-cream:#F7F6F2;isolation:isolate;position:relative;overflow:hidden;border-radius:clamp(1rem,2.5vw,1.75rem);min-height:clamp(430px,43vw,650px);display:grid;align-items:center;background:var(--lf-cream);font-family:Nunito,'Trebuchet MS',system-ui,sans-serif;color:var(--lf-navy)}
|
||||
.lf-hero *{box-sizing:border-box}.lf-hero__photo{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:68% center;z-index:-2}.lf-hero__photo[data-focus="right"]{object-position:80% center}.lf-hero__photo[data-focus="center-right"]{object-position:68% center}.lf-hero__photo[data-focus="center-left"]{object-position:35% center}.lf-hero__photo[data-focus="center"]{object-position:center}
|
||||
.lf-hero--photo-split::before{content:'';position:absolute;inset:0;z-index:-1;background:linear-gradient(90deg,rgba(250,249,243,.99) 0%,rgba(250,249,243,.97) 25%,rgba(250,249,243,.8) 39%,rgba(250,249,243,.20) 56%,rgba(250,249,243,0) 68%)}
|
||||
.lf-hero--editorial-solid{background:var(--lf-navy);color:white;min-height:350px}.lf-hero--editorial-solid .lf-hero__photo{display:none}.lf-hero--editorial-solid::before{content:'';position:absolute;width:55%;aspect-ratio:1;right:-25%;bottom:-75%;background:var(--lf-green);border-radius:50%;opacity:.75;z-index:-1}
|
||||
.lf-hero__inner{width:min(100%,1440px);margin:auto;padding:clamp(2rem,5vw,5rem);padding-block:clamp(3rem,6vw,5.5rem)}.lf-hero__copy{max-width:min(620px,57%)}.lf-hero__eyebrow{display:inline-block;padding:.35em .75em;border-radius:999px;background:#dff0c0;color:#17370b;font-weight:800;font-size:clamp(.8rem,.95vw,1rem)}.lf-hero__title{margin:.22em 0 .28em;font-size:clamp(2.5rem,4.8vw,5.25rem);line-height:1.05;letter-spacing:-.035em;font-weight:900;text-wrap:balance}.lf-hero__title-accent{width:clamp(110px,19vw,245px);height:7px;background:var(--lf-yellow);border-radius:90% 30% 45% 25%;transform:rotate(-1deg);margin-bottom:1.5rem}.lf-hero__description{max-width:56ch;font-size:clamp(1.05rem,1.45vw,1.35rem);line-height:1.48;margin:0 0 2rem}.lf-hero__actions{display:flex;gap:.8rem;flex-wrap:wrap}.lf-hero__button{display:inline-flex;align-items:center;justify-content:center;min-height:48px;padding:.8rem 1.25rem;border-radius:999px;text-decoration:none;font-weight:800;line-height:1.2;transition:transform .15s ease,background .15s ease;box-shadow:none}.lf-hero__button:hover{transform:translateY(-2px)}.lf-hero__button:focus-visible{outline:3px solid #1769aa;outline-offset:3px}.lf-hero__button--primary{background:var(--lf-green);color:#fff}.lf-hero__button--secondary{background:rgba(255,255,255,.92);color:var(--lf-navy);border:2px solid var(--lf-navy)}.lf-hero--editorial-solid .lf-hero__button--secondary{border-color:white}.lf-hero__bottom{position:absolute;inset:auto 0 0;height:17px;background:linear-gradient(105deg,var(--lf-yellow) 0%,var(--lf-yellow) 22%,var(--lf-green) 72%);clip-path:polygon(0 45%,30% 90%,65% 75%,100% 0,100% 100%,0 100%)}
|
||||
@media(max-width:850px){.lf-hero{min-height:unset;display:block}.lf-hero__photo{position:relative;display:block;width:100%;height:clamp(260px,53vw,440px);object-position:72% center}.lf-hero--photo-split::before{display:none}.lf-hero__inner{padding:2rem 1.5rem 2.8rem}.lf-hero__copy{max-width:100%}.lf-hero__title{font-size:clamp(2.15rem,7vw,3.6rem)}.lf-hero__description{font-size:1.05rem}.lf-hero--editorial-solid .lf-hero__copy{max-width:650px}}
|
||||
@media(max-width:420px){.lf-hero__photo{height:300px;object-position:72% center}.lf-hero__actions{display:grid;grid-template-columns:1fr}.lf-hero__button{width:100%}.lf-hero__inner{padding-inline:1.25rem}}
|
||||
@media(prefers-reduced-motion:reduce){.lf-hero__button{transition:none}.lf-hero__button:hover{transform:none}}
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"id": "lf-brand-hero",
|
||||
"version": 1,
|
||||
"status": "design candidate; not yet final code approval",
|
||||
"purpose": "CMS-wiederverwendbarer Marken-Hero; Darstellung und Inhalt getrennt",
|
||||
"layout_role": "single widget, full 4/4 slot recommended, minimum container width 320px",
|
||||
"variants": [
|
||||
"photo-split",
|
||||
"editorial-solid"
|
||||
],
|
||||
"fields": {
|
||||
"eyebrow": {
|
||||
"type": "string",
|
||||
"optional": true
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"description": {
|
||||
"type": "text",
|
||||
"optional": true
|
||||
},
|
||||
"image": {
|
||||
"type": "public_media_reference",
|
||||
"optional": true,
|
||||
"note": "Use approved public images, never member-restricted media"
|
||||
},
|
||||
"image_alt": {
|
||||
"type": "string",
|
||||
"optional": true,
|
||||
"note": "Meaningful if content image; alt empty if decorative"
|
||||
},
|
||||
"image_focal_point": {
|
||||
"type": "enum",
|
||||
"values": [
|
||||
"center",
|
||||
"center-right",
|
||||
"right",
|
||||
"center-left"
|
||||
],
|
||||
"default": "center-right"
|
||||
},
|
||||
"variant": {
|
||||
"type": "enum",
|
||||
"values": [
|
||||
"photo-split",
|
||||
"editorial-solid"
|
||||
],
|
||||
"default": "photo-split"
|
||||
},
|
||||
"primary_cta": {
|
||||
"type": "link",
|
||||
"optional": true,
|
||||
"fields": [
|
||||
"label",
|
||||
"url"
|
||||
]
|
||||
},
|
||||
"secondary_cta": {
|
||||
"type": "link",
|
||||
"optional": true,
|
||||
"fields": [
|
||||
"label",
|
||||
"url"
|
||||
]
|
||||
},
|
||||
"accent": {
|
||||
"type": "enum",
|
||||
"values": [
|
||||
"underline",
|
||||
"rays",
|
||||
"none"
|
||||
],
|
||||
"default": "underline"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
"use public media authorization logic",
|
||||
"escape textual fields by default",
|
||||
"validate destinations and block unsafe URL schemes",
|
||||
"no fake purchasable products or rights"
|
||||
],
|
||||
"integration": "Map fields to existing central Widget Registry; no separate schema or media database"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Lara & Felix – Hero Komponenten-Vorschau</title><link rel="stylesheet" href="../components/lf-hero.css"><style>body{margin:0;background:#eef0ec;color:#032551;font-family:system-ui,sans-serif}.demo{max-width:1600px;margin:auto;padding:24px}.panel{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px;margin:20px 0 28px;padding:18px;border-radius:14px;background:white}.panel label{display:grid;gap:5px;font-size:13px;font-weight:600}.panel input,.panel select,.panel textarea{font:inherit;padding:9px;border:1px solid #abbab6;border-radius:7px}.panel textarea{resize:vertical;min-height:60px}.note{font-size:14px;color:#405366;line-height:1.5}.preview{background:white;border-radius:22px;padding:12px}.foot{margin-top:32px}h1{font-size:22px}h2{font-size:18px}</style></head><body><main class="demo"><h1>Lara & Felix – konfigurierbarer Hero (Arbeitsstand)</h1><p class="note">Echtes Kling-Motiv unverändert verwendet. Text, CTA, Hintergrundvariante und Bildfokus sind unabhängig vom Bild editierbar. Dies ist ein statischer Demonstrator, noch keine Laravel-/Filament-Implementierung.</p><div class="panel" id="controls"><label>Variante<select id="variant"><option value="photo-split">Foto + Text</option><option value="editorial-solid">Navy Editorial</option></select></label><label>Überschrift<input id="title" value="Kinder stark im Alltag"></label><label>Einleitung<textarea id="description">Alltagsnahe Filme, Übungen und didaktische Materialien für die Präventionsarbeit mit Kindern.</textarea></label><label>Erster Button<input id="cta1" value="Materialien entdecken"></label><label>Zweiter Button<input id="cta2" value="Für Trainer und Einrichtungen"></label><label>Bildfokus<select id="focal"><option value="center-right">Mitte rechts</option><option value="right">Rechts</option><option value="center">Mitte</option><option value="center-left">Mitte links</option></select></label></div><div class="preview"><section class="lf-hero lf-hero--photo-split" id="hero"><img class="lf-hero__photo" src="../assets/lara-felix-park-hero.webp" alt="Lara und Felix stehen gemeinsam in einem Park" data-focus="center-right"><div class="lf-hero__inner"><div class="lf-hero__copy"><span class="lf-hero__eyebrow">Lara & Felix · Stark im Alltag</span><h2 class="lf-hero__title" id="heroTitle">Kinder stark im Alltag</h2><div class="lf-hero__title-accent" aria-hidden="true"></div><p class="lf-hero__description" id="heroDescription">Alltagsnahe Filme, Übungen und didaktische Materialien für die Präventionsarbeit mit Kindern.</p><div class="lf-hero__actions"><a href="#demo" class="lf-hero__button lf-hero__button--primary" id="button1">Materialien entdecken</a><a href="#demo" class="lf-hero__button lf-hero__button--secondary" id="button2">Für Trainer und Einrichtungen</a></div></div></div><span class="lf-hero__bottom" aria-hidden="true"></span></section></div><p class="note foot" id="demo">Demo-Links sind absichtlich nicht mit realen Zielseiten verbunden. Bildrechte und öffentliche Freigabe im CMS prüfen. Auf Mobilgeräten wird das Foto oberhalb des Textes gezeigt, damit Gesichter nicht durch eine Textüberlagerung verdeckt werden.</p></main><script>const $=x=>document.getElementById(x);const render=()=>{const h=$('hero');h.className='lf-hero lf-hero--'+$('variant').value;$('heroTitle').textContent=$('title').value;$('heroDescription').textContent=$('description').value;$('button1').textContent=$('cta1').value;$('button2').textContent=$('cta2').value;$('button1').hidden=!$('cta1').value.trim();$('button2').hidden=!$('cta2').value.trim();document.querySelector('.lf-hero__photo').dataset.focus=$('focal').value};$('controls').addEventListener('input',render);$('controls').addEventListener('change',render);</script></body></html>
|
||||
@@ -0,0 +1,11 @@
|
||||
# Lara & Felix – Bild & Text (Designentwurf v1.4)
|
||||
|
||||
Öffne `preview/index.html`. Die Vorschau funktioniert lokal ohne Server.
|
||||
|
||||
**Lieferumfang:** HTML-Demo, separates CSS, Original-Kling-Bild als WebP, JSON-Feldvertrag.
|
||||
|
||||
**Varianten:** Bild links/rechts; creme/transparente/Navy-Fläche; responsive Aufteilung anhand Slotbreite.
|
||||
|
||||
**Status:** Gestalterischer Arbeitsstand, noch nicht vom Auftraggeber freigegeben und nicht in Laravel/Filament integriert. Text ist Demonstrationsinhalt, keine abgestimmte Website-Redaktion.
|
||||
|
||||
**Integration:** An bestehende CMS-Widget-Registry anschließen; vorhandene Medienauswahl nutzen. Kein neues Datenmodell. Widget-Klasse, Formularfelder und Blade-View müssen im Repository passend angelegt werden. Originales Foto bleibt als eigenständiges Bild erhalten.
|
||||
|
After Width: | Height: | Size: 244 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 28"><path d="M9 18 Q102 1 270 12" fill="none" stroke="#FCD10A" stroke-width="13" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 168 B |
@@ -0,0 +1,54 @@
|
||||
/* Lara & Felix | Bild-und-Text-Widget | Design-Arbeitsstand v1.4 */
|
||||
:root{
|
||||
--lf-navy:#032551; --lf-green:#3B7B09; --lf-yellow:#FCD10A; --lf-cream:#F7F6F2;
|
||||
--lf-ink:#032551; --lf-muted:#46556B; --lf-radius:24px;
|
||||
--lf-font: "Nunito Sans", "Arial", system-ui, sans-serif;
|
||||
}
|
||||
.lf-bt-host{container-type:inline-size;container-name:lf-bildtext;width:100%;}
|
||||
.lf-bt{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.04fr);gap:clamp(24px,4vw,76px);align-items:center;
|
||||
min-width:0;color:var(--lf-navy);border-radius:28px;padding:clamp(22px,4.4vw,72px);background:var(--lf-cream);
|
||||
font-family:var(--lf-font);isolation:isolate;overflow:hidden;}
|
||||
.lf-bt--clear{background:transparent;}
|
||||
.lf-bt--navy{background:var(--lf-navy);color:#fff;}
|
||||
.lf-bt--navy .lf-bt__text{color:#f3f6fa;}
|
||||
.lf-bt--navy .lf-bt__eyebrow{color:#fdf4b7;}
|
||||
.lf-bt--image-left .lf-bt__media{order:-1;}
|
||||
.lf-bt__copy{min-width:0;max-width:640px;}
|
||||
.lf-bt__eyebrow{display:inline-flex;align-items:center;gap:9px;color:#295b08;font-weight:850;
|
||||
letter-spacing:.095em;font-size:clamp(11px,.95vw,13px);text-transform:uppercase;margin-bottom:20px;}
|
||||
.lf-bt__eyebrow:before{content:"";display:block;width:25px;height:4px;background:var(--lf-yellow);border-radius:99px;}
|
||||
.lf-bt__headline{font-size:clamp(32px,3.2vw,56px);line-height:1.1;letter-spacing:-.035em;font-weight:850;
|
||||
margin:0 0 23px;max-width:660px;}
|
||||
.lf-bt__accent{width:112px;height:7px;background:var(--lf-yellow);border-radius:90% 40% 80% 40%;margin: -8px 0 26px 3px;transform:rotate(-1deg);}
|
||||
.lf-bt__text{font-size:clamp(16px,1.12vw,20px);line-height:1.65;margin:0 0 30px;color:var(--lf-muted);max-width:580px;}
|
||||
.lf-bt__actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
|
||||
.lf-bt__button{display:inline-flex;align-items:center;gap:13px;padding:13px 22px;background:var(--lf-green);color:white;
|
||||
border:2px solid var(--lf-green);font-weight:800;text-decoration:none;border-radius:100px;min-height:50px;font-size:15px;
|
||||
transition:transform .12s ease,background .12s ease;}
|
||||
.lf-bt__button:hover{background:#285a06;transform:translateY(-1px)}
|
||||
.lf-bt__button:focus-visible{outline:3px solid var(--lf-yellow);outline-offset:4px;}
|
||||
.lf-bt__button--secondary{background:transparent;color:inherit;border-color:currentColor;}
|
||||
.lf-bt__button--secondary:hover{background:rgba(255,255,255,.09)}
|
||||
.lf-bt__media{position:relative;min-width:0;align-self:stretch;display:flex;align-items:stretch;}
|
||||
.lf-bt__photo{display:block;width:100%;height:100%;min-height:365px;max-height:650px;object-fit:cover;object-position:var(--lf-object-position,64% center);
|
||||
border-radius:22px;box-shadow:0 20px 42px rgba(3,37,81,.12);position:relative;z-index:1;}
|
||||
.lf-bt__media:before{content:"";position:absolute;inset:auto -13px -13px 28px;height:55%;background:#8ab848;
|
||||
border-radius:25px;z-index:0;transform:rotate(1.8deg);}
|
||||
.lf-bt--navy .lf-bt__media:before{background:var(--lf-yellow);}
|
||||
.lf-bt__media-label{position:absolute;z-index:2;left:20px;bottom:20px;background:#fff;color:var(--lf-navy);
|
||||
padding:9px 14px;border-radius:14px;font-size:13px;font-weight:850;box-shadow:0 8px 24px rgba(3,37,81,.15);}
|
||||
@container lf-bildtext (max-width: 780px){
|
||||
.lf-bt{grid-template-columns:1fr;padding:clamp(20px,4vw,36px);gap:25px;border-radius:19px;}
|
||||
.lf-bt__media,.lf-bt--image-left .lf-bt__media{order:-1;}
|
||||
.lf-bt__photo{min-height:0;aspect-ratio:1.45 / 1;max-height:430px;}
|
||||
.lf-bt__headline{font-size:clamp(28px,5.7cqw,42px);margin-bottom:17px;}
|
||||
.lf-bt__text{font-size:16px;}
|
||||
.lf-bt__media:before{inset:auto -8px -8px 25px;}
|
||||
}
|
||||
@container lf-bildtext (max-width: 450px){
|
||||
.lf-bt__photo{aspect-ratio:1.45 / 1;object-position:right center;}
|
||||
.lf-bt__actions{display:grid;}
|
||||
.lf-bt__button{justify-content:center;width:100%;box-sizing:border-box;}
|
||||
.lf-bt__media-label{font-size:11px;left:10px;bottom:10px;}
|
||||
}
|
||||
@media (prefers-reduced-motion:reduce){.lf-bt__button{transition:none}.lf-bt__button:hover{transform:none}}
|
||||
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"widget_id": "lf-editorial-bild-text",
|
||||
"version": 1,
|
||||
"status": "design-draft, not integrated with Laravel",
|
||||
"layout_scope": "one CMS widget slot, width-responsive through container queries",
|
||||
"fields": {
|
||||
"eyebrow": {
|
||||
"type": "string",
|
||||
"optional": true
|
||||
},
|
||||
"headline": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"body": {
|
||||
"type": "richtext",
|
||||
"required": true
|
||||
},
|
||||
"image_reference": {
|
||||
"type": "public-media-reference",
|
||||
"required": true
|
||||
},
|
||||
"image_alt": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"image_focus": {
|
||||
"type": "focal_point",
|
||||
"optional": true
|
||||
},
|
||||
"primary_cta": {
|
||||
"type": "internal-link+label",
|
||||
"optional": true
|
||||
},
|
||||
"secondary_cta": {
|
||||
"type": "internal-link+label",
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"variant_fields": {
|
||||
"image_side": [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
"surface": [
|
||||
"cream",
|
||||
"clear",
|
||||
"navy"
|
||||
]
|
||||
},
|
||||
"assets": {
|
||||
"demo_image": "assets/lara-felix-park.webp",
|
||||
"accent": "assets/yellow-underline.svg"
|
||||
},
|
||||
"notes": [
|
||||
"Uses publicly permitted images only in public version; protection must be checked in Laravel",
|
||||
"Front-end markup and CSS are a portable preview, not a Filament widget implementation",
|
||||
"No content copied into separate program/module model"
|
||||
]
|
||||
}
|
||||