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; } }