Öffne Katalog, Bibliothek und Testkauf für den MVP.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
463851d402
commit
fd6860efda
51 files changed
+2331
-31
No files matched your search
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('manual_grants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('actor_id')->constrained('users')->restrictOnDelete();
|
||||
$table->foreignId('party_id')->constrained()->restrictOnDelete();
|
||||
$table->foreignId('offer_id')->constrained()->restrictOnDelete();
|
||||
$table->text('reason');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->restrictOnDelete();
|
||||
$table->foreignId('party_id')->constrained()->restrictOnDelete();
|
||||
$table->string('status');
|
||||
$table->string('holder_kind');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('order_lines', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('order_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('offer_version_id')->constrained()->restrictOnDelete();
|
||||
$table->unsignedInteger('price_cents');
|
||||
$table->string('term_rule');
|
||||
$table->string('update_promise');
|
||||
$table->string('holder_kind');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['order_id', 'offer_version_id']);
|
||||
});
|
||||
|
||||
Schema::create('order_scope_items', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('order_line_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('license_article_id')->constrained()->restrictOnDelete();
|
||||
$table->foreignId('rights_profile_version_id')->constrained()->restrictOnDelete();
|
||||
$table->json('rights_snapshot');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['order_line_id', 'license_article_id', 'rights_profile_version_id'], 'order_scope_unique');
|
||||
});
|
||||
|
||||
Schema::create('payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('order_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('provider');
|
||||
$table->string('status');
|
||||
$table->string('provider_reference')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('payments');
|
||||
Schema::dropIfExists('order_scope_items');
|
||||
Schema::dropIfExists('order_lines');
|
||||
Schema::dropIfExists('orders');
|
||||
Schema::dropIfExists('manual_grants');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user