Fix Event & EventType resource issues and apply formatting

- Fix EventType deletion error handling (constraint violations)
- Fix Event update error (package_id column missing)
- Fix Event Type dropdown options (JSON display issue)
- Fix EventPackagesRelationManager query error
- Add missing translations for deletion errors
- Apply Pint formatting
This commit is contained in:
Codex Agent
2026-01-21 10:34:06 +01:00
parent 198fbf6751
commit fa33e7cbcf
112 changed files with 334 additions and 280 deletions

View File

@@ -69,13 +69,13 @@ return new class extends Migration
]
: null;
$slugBase = Str::slug($name ?: ('collection-' . $row->id));
$slugBase = Str::slug($name ?: ('collection-'.$row->id));
if (empty($slugBase)) {
$slugBase = 'collection-' . $row->id;
$slugBase = 'collection-'.$row->id;
}
$slug = $row->slug ?: ($slugBase . '-' . $row->id);
$slug = $row->slug ?: ($slugBase.'-'.$row->id);
DB::table('task_collections')
->where('id', $row->id)
@@ -127,11 +127,11 @@ return new class extends Migration
return;
}
DB::table('tasks')
->select('id', 'slug', 'title')
->orderBy('id')
->chunk(100, function ($rows) {
foreach ($rows as $row) {
DB::table('tasks')
->select('id', 'slug', 'title')
->orderBy('id')
->chunk(100, function ($rows) {
foreach ($rows as $row) {
if (! empty($row->slug)) {
continue;
}
@@ -146,21 +146,21 @@ return new class extends Migration
$base = $json['de']
?? $json['en']
?? ('task-' . $row->id);
?? ('task-'.$row->id);
$slug = Str::slug($base);
if (empty($slug)) {
$slug = 'task-' . $row->id;
$slug = 'task-'.$row->id;
}
DB::table('tasks')
->where('id', $row->id)
->update([
'slug' => $slug . '-' . $row->id,
'slug' => $slug.'-'.$row->id,
]);
}
});
}
});
Schema::table('tasks', function (Blueprint $table) {
$table->unique('slug');
@@ -232,7 +232,7 @@ return new class extends Migration
DB::table('task_collections')
->where('id', $row->id)
->update([
'name' => $names['de'] ?? $names['en'] ?? 'Collection ' . $row->id,
'name' => $names['de'] ?? $names['en'] ?? 'Collection '.$row->id,
'description' => $descriptions['de'] ?? $descriptions['en'] ?? null,
]);
}

View File

@@ -9,7 +9,7 @@ return new class extends Migration
public function up(): void
{
// Create tenants table if not exists
if (!Schema::hasTable('tenants')) {
if (! Schema::hasTable('tenants')) {
Schema::create('tenants', function (Blueprint $table) {
$table->id();
$table->string('name');
@@ -32,7 +32,7 @@ return new class extends Migration
});
} else {
// Add missing columns to existing tenants table
if (!Schema::hasColumn('tenants', 'email')) {
if (! Schema::hasColumn('tenants', 'email')) {
Schema::table('tenants', function (Blueprint $table) {
$table->string('email')->nullable()->after('contact_phone');
});
@@ -42,17 +42,17 @@ return new class extends Migration
$table->dropColumn(['event_credits_balance', 'free_event_granted_at']);
});
}
if (!Schema::hasColumn('tenants', 'stripe_account_id')) {
if (! Schema::hasColumn('tenants', 'stripe_account_id')) {
Schema::table('tenants', function (Blueprint $table) {
$table->string('stripe_account_id')->nullable()->after('features');
});
}
if (!Schema::hasColumn('tenants', 'custom_domain')) {
if (! Schema::hasColumn('tenants', 'custom_domain')) {
Schema::table('tenants', function (Blueprint $table) {
$table->string('custom_domain')->nullable()->after('domain');
});
}
if (!Schema::hasColumn('tenants', 'user_id')) {
if (! Schema::hasColumn('tenants', 'user_id')) {
Schema::table('tenants', function (Blueprint $table) {
$table->foreignId('user_id')->nullable()->constrained('users')->onDelete('cascade')->after('id');
});
@@ -68,7 +68,7 @@ return new class extends Migration
});
}
// Add subscription fields (from add_subscription_fields_to_tenants_table)
if (!Schema::hasColumn('tenants', 'subscription_status')) {
if (! Schema::hasColumn('tenants', 'subscription_status')) {
Schema::table('tenants', function (Blueprint $table) {
$table->string('subscription_status')->default('active')->after('event_credits_balance');
$table->timestamp('subscription_ends_at')->nullable()->after('subscription_status');
@@ -77,14 +77,14 @@ return new class extends Migration
}
// Add tenant_id to users if not exists
if (Schema::hasTable('users') && !Schema::hasColumn('users', 'tenant_id')) {
if (Schema::hasTable('users') && ! Schema::hasColumn('users', 'tenant_id')) {
Schema::table('users', function (Blueprint $table) {
$table->foreignId('tenant_id')->nullable()->after('id')->constrained('tenants')->nullOnDelete();
});
}
// Add tenant_id to events if not exists
if (Schema::hasTable('events') && !Schema::hasColumn('events', 'tenant_id')) {
if (Schema::hasTable('events') && ! Schema::hasColumn('events', 'tenant_id')) {
Schema::table('events', function (Blueprint $table) {
$table->foreignId('tenant_id')->nullable()->after('id')->constrained('tenants')->nullOnDelete();
});

View File

@@ -9,7 +9,7 @@ return new class extends Migration
public function up(): void
{
// Event Types
if (!Schema::hasTable('event_types')) {
if (! Schema::hasTable('event_types')) {
Schema::create('event_types', function (Blueprint $table) {
$table->id();
$table->json('name');
@@ -21,7 +21,7 @@ return new class extends Migration
}
// Emotions
if (!Schema::hasTable('emotions')) {
if (! Schema::hasTable('emotions')) {
Schema::create('emotions', function (Blueprint $table) {
$table->id();
$table->json('name');
@@ -35,7 +35,7 @@ return new class extends Migration
}
// Pivot table for emotions and event types
if (!Schema::hasTable('emotion_event_type')) {
if (! Schema::hasTable('emotion_event_type')) {
Schema::create('emotion_event_type', function (Blueprint $table) {
$table->unsignedBigInteger('emotion_id');
$table->unsignedBigInteger('event_type_id');
@@ -54,4 +54,4 @@ return new class extends Migration
Schema::dropIfExists('event_types');
}
}
};
};

View File

@@ -10,7 +10,7 @@ return new class extends Migration
public function up(): void
{
// Legal Pages table
if (!Schema::hasTable('legal_pages')) {
if (! Schema::hasTable('legal_pages')) {
Schema::create('legal_pages', function (Blueprint $table) {
$table->id();
$table->string('slug', 32);
@@ -86,7 +86,7 @@ return new class extends Migration
private function impressumDe(): string
{
return <<<MD
return <<<'MD'
# Impressum
Anbieter dieser Seiten:
@@ -223,4 +223,4 @@ Es gilt deutsches Recht. Gerichtsstand ist, soweit zulässig, der Sitz des Betre
Stand: {$date}
MD;
}
};
};

View File

@@ -9,7 +9,7 @@ return new class extends Migration
public function up(): void
{
// Blog Categories
if (!Schema::hasTable('blog_categories')) {
if (! Schema::hasTable('blog_categories')) {
Schema::create('blog_categories', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
@@ -21,13 +21,13 @@ return new class extends Migration
$table->timestamps();
});
} else {
if (!Schema::hasColumn('blog_categories', 'name')) {
if (! Schema::hasColumn('blog_categories', 'name')) {
Schema::table('blog_categories', function (Blueprint $table) {
$table->string('name')->nullable()->after('id');
$table->longText('description')->nullable()->after('name');
});
}
if (!Schema::hasColumn('blog_categories', 'translations')) {
if (! Schema::hasColumn('blog_categories', 'translations')) {
Schema::table('blog_categories', function (Blueprint $table) {
$table->json('translations')->nullable()->after('description');
});
@@ -35,7 +35,7 @@ return new class extends Migration
}
// Blog Authors
if (!Schema::hasTable('blog_authors')) {
if (! Schema::hasTable('blog_authors')) {
Schema::create('blog_authors', function (Blueprint $table) {
$table->id();
$table->string('name');
@@ -49,7 +49,7 @@ return new class extends Migration
}
// Blog Posts
if (!Schema::hasTable('blog_posts')) {
if (! Schema::hasTable('blog_posts')) {
Schema::create('blog_posts', function (Blueprint $table) {
$table->id();
$table->foreignId('blog_author_id')->nullable()->constrained()->cascadeOnDelete();
@@ -65,7 +65,7 @@ return new class extends Migration
$table->timestamps();
});
} else {
if (!Schema::hasColumn('blog_posts', 'translations')) {
if (! Schema::hasColumn('blog_posts', 'translations')) {
Schema::table('blog_posts', function (Blueprint $table) {
$table->json('translations')->nullable()->after('content');
});
@@ -73,7 +73,7 @@ return new class extends Migration
}
// Tags
if (!Schema::hasTable('tags')) {
if (! Schema::hasTable('tags')) {
Schema::create('tags', function (Blueprint $table) {
$table->id();
$table->json('name');
@@ -85,7 +85,7 @@ return new class extends Migration
}
// Taggables (polymorphic)
if (!Schema::hasTable('taggables')) {
if (! Schema::hasTable('taggables')) {
Schema::create('taggables', function (Blueprint $table) {
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
$table->morphs('taggable');
@@ -124,4 +124,4 @@ return new class extends Migration
Schema::dropIfExists('blog_categories');
}
}
};
};

View File

@@ -12,16 +12,16 @@ return new class extends Migration
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
if (!Schema::hasColumn('tenants', 'first_name')) {
if (! Schema::hasColumn('tenants', 'first_name')) {
$table->string('first_name')->default('')->after('name');
}
if (!Schema::hasColumn('tenants', 'last_name')) {
if (! Schema::hasColumn('tenants', 'last_name')) {
$table->string('last_name')->default('')->after('first_name');
}
if (!Schema::hasColumn('tenants', 'address')) {
if (! Schema::hasColumn('tenants', 'address')) {
$table->string('address')->nullable()->after('last_name');
}
if (!Schema::hasColumn('tenants', 'phone')) {
if (! Schema::hasColumn('tenants', 'phone')) {
$table->string('phone')->nullable()->after('address');
}
});
@@ -36,4 +36,4 @@ return new class extends Migration
$table->dropColumn(['first_name', 'last_name', 'address', 'phone']);
});
}
};
};

View File

@@ -25,4 +25,4 @@ return new class extends Migration
$table->string('provider_id')->nullable(false)->change();
});
}
};
};

View File

@@ -12,13 +12,13 @@ return new class extends Migration
public function up(): void
{
Schema::table('tenants', function (Blueprint $table) {
if (!Schema::hasColumn('tenants', 'is_suspended')) {
if (! Schema::hasColumn('tenants', 'is_suspended')) {
$table->boolean('is_suspended')->default(false)->after('is_active');
}
if (!Schema::hasColumn('tenants', 'settings')) {
if (! Schema::hasColumn('tenants', 'settings')) {
$table->json('settings')->nullable()->after('subscription_expires_at');
}
if (!Schema::hasColumn('tenants', 'settings_updated_at')) {
if (! Schema::hasColumn('tenants', 'settings_updated_at')) {
$table->timestamp('settings_updated_at')->nullable()->after('settings');
}
});
@@ -33,4 +33,4 @@ return new class extends Migration
$table->dropColumn(['is_suspended', 'settings', 'settings_updated_at']);
});
}
};
};

View File

@@ -2,8 +2,8 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
return new class extends Migration
@@ -14,10 +14,10 @@ return new class extends Migration
public function up(): void
{
Schema::table('packages', function (Blueprint $table) {
if (!Schema::hasColumn('packages', 'slug')) {
if (! Schema::hasColumn('packages', 'slug')) {
$table->string('slug')->default('')->after('name');
}
if (!Schema::hasColumn('packages', 'description')) {
if (! Schema::hasColumn('packages', 'description')) {
$table->text('description')->nullable()->after('slug');
}
});
@@ -26,7 +26,7 @@ return new class extends Migration
if (Schema::hasTable('packages')) {
$packages = DB::table('packages')->get();
foreach ($packages as $package) {
$slug = Str::slug($package->name . '-' . $package->id);
$slug = Str::slug($package->name.'-'.$package->id);
DB::table('packages')->where('id', $package->id)->update(['slug' => $slug]);
}
}
@@ -49,4 +49,4 @@ return new class extends Migration
$table->dropColumn(['slug', 'description']);
});
}
};
};

View File

@@ -25,4 +25,4 @@ return new class extends Migration
$table->string('name')->after('id');
});
}
};
};

View File

@@ -25,4 +25,4 @@ return new class extends Migration
$table->dropColumn('pending_purchase');
});
}
};
};

View File

@@ -40,7 +40,7 @@ return new class extends Migration
}
$translations = $this->decodeTranslations($row->name_translations);
$base = $translations['en'] ?? $translations['de'] ?? reset($translations) ?? ('collection-' . $row->id);
$base = $translations['en'] ?? $translations['de'] ?? reset($translations) ?? ('collection-'.$row->id);
$slug = $this->buildUniqueSlug($base, 'collection-', function ($candidate) {
return DB::table('task_collections')->where('slug', $candidate)->exists();
});
@@ -76,7 +76,7 @@ return new class extends Migration
}
$translations = $this->decodeTranslations($row->title);
$base = $translations['en'] ?? $translations['de'] ?? reset($translations) ?? ('task-' . $row->id);
$base = $translations['en'] ?? $translations['de'] ?? reset($translations) ?? ('task-'.$row->id);
$slug = $this->buildUniqueSlug($base, 'task-', function ($candidate) {
return DB::table('tasks')->where('slug', $candidate)->exists();
});
@@ -139,10 +139,10 @@ return new class extends Migration
protected function buildUniqueSlug(string $base, string $prefix, callable $exists): string
{
$slugBase = Str::slug($base) ?: ($prefix . Str::random(4));
$slugBase = Str::slug($base) ?: ($prefix.Str::random(4));
do {
$candidate = $slugBase . '-' . Str::random(4);
$candidate = $slugBase.'-'.Str::random(4);
} while ($exists($candidate));
return $candidate;

View File

@@ -9,7 +9,7 @@ return new class extends Migration
public function up(): void
{
Schema::table('packages', function (Blueprint $table) {
if (!Schema::hasColumn('packages', 'description_table')) {
if (! Schema::hasColumn('packages', 'description_table')) {
$table->json('description_table')->nullable()->after('description');
}
});

View File

@@ -2,8 +2,8 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{

View File

@@ -33,4 +33,3 @@ return new class extends Migration
Schema::dropIfExists('media_storage_targets');
}
};

View File

@@ -34,4 +34,3 @@ return new class extends Migration
Schema::dropIfExists('event_storage_assignments');
}
};

View File

@@ -43,4 +43,3 @@ return new class extends Migration
Schema::dropIfExists('event_media_assets');
}
};

View File

@@ -24,4 +24,3 @@ return new class extends Migration
});
}
};

View File

@@ -13,17 +13,17 @@ return new class extends Migration
$addedTokenHashColumn = false;
Schema::table('event_join_tokens', function (Blueprint $table) use (&$addedTokenHashColumn) {
if (!Schema::hasColumn('event_join_tokens', 'token_hash')) {
if (! Schema::hasColumn('event_join_tokens', 'token_hash')) {
$table->string('token_hash', 128)->nullable()->after('token');
$table->index('token_hash', 'event_join_tokens_token_hash_index');
$addedTokenHashColumn = true;
}
if (!Schema::hasColumn('event_join_tokens', 'token_encrypted')) {
if (! Schema::hasColumn('event_join_tokens', 'token_encrypted')) {
$table->text('token_encrypted')->nullable()->after('token_hash');
}
if (!Schema::hasColumn('event_join_tokens', 'token_preview')) {
if (! Schema::hasColumn('event_join_tokens', 'token_preview')) {
$table->string('token_preview', 32)->nullable()->after('token_encrypted');
}
});
@@ -33,20 +33,20 @@ return new class extends Migration
->whereNotNull('token')
->orderBy('id')
->chunkById(200, function ($tokens) {
foreach ($tokens as $token) {
$hash = hash('sha256', $token->token);
$preview = $this->previewToken($token->token);
foreach ($tokens as $token) {
$hash = hash('sha256', $token->token);
$preview = $this->previewToken($token->token);
DB::table('event_join_tokens')
->where('id', $token->id)
->update([
'token_hash' => $hash,
'token_encrypted' => Crypt::encryptString($token->token),
'token_preview' => $preview,
'token' => $hash,
]);
}
});
DB::table('event_join_tokens')
->where('id', $token->id)
->update([
'token_hash' => $hash,
'token_encrypted' => Crypt::encryptString($token->token),
'token_preview' => $preview,
'token' => $hash,
]);
}
});
if ($addedTokenHashColumn) {
Schema::table('event_join_tokens', function (Blueprint $table) {
@@ -76,7 +76,7 @@ return new class extends Migration
->filter(fn ($column) => Schema::hasColumn('event_join_tokens', $column))
->all();
if (!empty($columns)) {
if (! empty($columns)) {
$table->dropColumn($columns);
}
});

View File

@@ -23,4 +23,3 @@ return new class extends Migration
});
}
};

View File

@@ -35,4 +35,3 @@ return new class extends Migration
Schema::dropIfExists('event_join_token_events');
}
};

View File

@@ -1,7 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration