übergang auf pakete, integration von stripe und paypal, blog hinzugefügt.

This commit is contained in:
Codex Agent
2025-09-29 07:59:39 +02:00
parent 0a643c3e4d
commit e52a4005aa
83 changed files with 4284 additions and 629 deletions

View File

@@ -10,8 +10,8 @@ return new class extends Migration {
Schema::create('events', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->onDelete('cascade');
$table->string('name');
$table->text('description')->nullable();
$table->json('name');
$table->json('description')->nullable();
$table->dateTime('date');
$table->string('slug')->unique();
$table->string('location')->nullable();

View File

@@ -12,9 +12,9 @@ return new class extends Migration {
$table->foreignId('tenant_id')->constrained()->onDelete('cascade');
$table->unsignedBigInteger('emotion_id')->nullable();
$table->unsignedBigInteger('event_type_id')->nullable();
$table->string('title');
$table->text('description')->nullable();
$table->text('example_text')->nullable();
$table->json('title');
$table->json('description')->nullable();
$table->json('example_text')->nullable();
$table->dateTime('due_date')->nullable();
$table->boolean('is_completed')->default(false);
$table->enum('priority', ['low', 'medium', 'high', 'urgent'])->default('medium');

View File

@@ -72,7 +72,7 @@ return new class extends Migration
}
// Migrate tenant credits to tenant_packages (Free package)
DB::table('tenants')->where('event_credits_balance', '>', 0)->chunk(100, function ($tenants) {
DB::table('tenants')->where('event_credits_balance', '>', 0)->orderBy('id')->chunk(100, function ($tenants) {
foreach ($tenants as $tenant) {
$freePackageId = DB::table('packages')->where('name', 'Free/Test')->first()->id;
DB::table('tenant_packages')->insert([
@@ -106,7 +106,7 @@ return new class extends Migration
});
// Migrate event purchases to event_packages (if any existing events)
DB::table('events')->chunk(100, function ($events) {
DB::table('events')->orderBy('id')->chunk(100, function ($events) {
foreach ($events as $event) {
if ($event->tenant->event_credits_balance > 0) { // or check if event was created with credits
$freePackageId = DB::table('packages')->where('name', 'Free/Test')->first()->id;

View File

@@ -15,15 +15,37 @@ return new class extends Migration
Schema::dropIfExists('purchase_history');
Schema::dropIfExists('event_purchases');
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn([
'event_credits_balance',
'subscription_tier',
'subscription_expires_at',
'free_event_granted_at',
'total_revenue'
]);
});
if (Schema::hasTable('package_purchases')) {
Schema::table('package_purchases', function (Blueprint $table) {
$table->dropIndex(['tenant_id', 'purchased_at']);
});
}
if (Schema::hasColumn('tenants', 'event_credits_balance')) {
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn('event_credits_balance');
});
}
if (Schema::hasColumn('tenants', 'subscription_tier')) {
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn('subscription_tier');
});
}
if (Schema::hasColumn('tenants', 'subscription_expires_at')) {
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn('subscription_expires_at');
});
}
if (Schema::hasColumn('tenants', 'free_event_granted_at')) {
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn('free_event_granted_at');
});
}
if (Schema::hasColumn('tenants', 'total_revenue')) {
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn('total_revenue');
});
}
}
/**

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('first_name')->nullable()->after('name');
$table->string('last_name')->nullable()->after('first_name');
$table->text('address')->nullable()->after('last_name');
$table->string('phone')->nullable()->after('address');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['first_name', 'last_name', 'address', 'phone']);
});
}
};

View File

@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->foreignId('user_id')->nullable()->constrained('users')->onDelete('cascade')->after('id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->dropForeign(['user_id']);
$table->dropColumn('user_id');
});
}
};

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('package_purchases', function (Blueprint $table) {
$table->dropForeign(['tenant_id']);
$table->foreignId('tenant_id')->constrained()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('package_purchases', function (Blueprint $table) {
$table->dropForeign(['tenant_id']);
$table->foreignId('tenant_id')->nullable()->constrained()->change();
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->unique('username');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropUnique(['username']);
});
}
};