Files
laraundfelix/database/seeders/DemoCatalogSeeder.php
T
LarsandCursor 3ee9f529ca
Deploy Test / test (push) Successful in 13s
Deploy Test / deploy (push) Successful in 23s
Mache Medien, Übungen und Kurse in der Verwaltung bearbeitbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-15 10:49:35 +01:00

72 lines
2.9 KiB
PHP

<?php
namespace Database\Seeders;
use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\BundleService;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\OfferService;
use Illuminate\Database\Seeder;
class DemoCatalogSeeder extends Seeder
{
public function run(): void
{
if (LicenseArticle::query()->where('code', 'demo-merkblatt')->exists()) {
return;
}
$content = app(ContentService::class);
$articles = app(ArticleService::class);
$bundles = app(BundleService::class);
$offers = app(OfferService::class);
$sheet = $content->publishElementVersion(
$content->createElement('pdf', 'pdf', 'Merkblatt Alltag'),
'Kurzer Hinweis für die Erprobung. Kein echtes Kursmaterial.',
);
$film = $content->publishElementVersion(
$content->createElement('film', 'film', 'Übungsfilm Alltag'),
'Für die geschützte Wiedergabe in der Verwaltung eine Filmdatei als weitere Fassung hochladen.',
['decision_seconds' => 42],
);
$inner = $content->publishComposition(
$content->createComposition('Materialsatz Alltag', CompositionKind::Kombination),
[['role' => 'Merkblatt', 'target' => $sheet]],
);
$exercise = $content->publishComposition(
$content->createComposition('Übung Alltag'),
[
['role' => 'Film', 'target' => $film],
['role' => 'Materialsatz', 'target' => $inner],
],
);
$sheetArticle = $articles->create('demo-merkblatt', 'Erprobung');
$articles->publishRelease($sheetArticle, $sheet, 'Eigenständiges Merkblatt für die Erprobung.');
$exerciseArticle = $articles->create('demo-uebung', 'Erprobung');
$articles->publishRelease($exerciseArticle, $exercise, 'Übung aus Film und Materialsatz, zur Erprobung.');
$basis = $bundles->create('Demo Basis');
$bundles->publish($basis, [$sheetArticle->fresh()]);
$program = $bundles->create('Demo Programm');
$programVersion = $bundles->publish($program, [$basis, $exerciseArticle->fresh()]);
$rights = $offers->createRightsProfile('Erprobung lesen und ansehen', 'ehrenamtlich', [
'pdf' => ['ansehen', 'laden'],
'film' => ['streamen', 'ansehen'],
'text' => ['ansehen'],
]);
$free = $offers->create('Kostenloses Merkblatt');
$offers->activate($free, [
['target' => $sheetArticle->fresh(), 'rights' => $rights],
], ['grant_kind' => 'auf_abruf']);
$paid = $offers->create('Testkauf Programm');
$offers->activate($paid, [
['target' => $programVersion, 'rights' => $rights],
], ['grant_kind' => 'kauf', 'price_cents' => 500]);
}
}