70 lines
2.8 KiB
PHP
70 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Domain\Catalog\ArticleService;
|
|
use App\Domain\Catalog\BundleService;
|
|
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.',
|
|
);
|
|
$inner = $content->publishComposition(
|
|
$content->createComposition('Materialsatz Alltag'),
|
|
[['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]);
|
|
}
|
|
}
|