Implement multi-tenancy support with OAuth2 authentication for tenant admins, Stripe integration for event purchases and credits ledger, new Filament resources for event purchases, updated API routes and middleware for tenant isolation and token guarding, added factories/seeders/migrations for new models (Tenant, EventPurchase, OAuth entities, etc.), enhanced tests, and documentation updates. Removed outdated DemoAchievementsSeeder.

This commit is contained in:
2025-09-17 19:56:54 +02:00
parent 5fbb9cb240
commit 42d6e98dff
84 changed files with 6125 additions and 155 deletions

View File

@@ -3,8 +3,7 @@
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use App\Models\{Event, Task, TaskCollection, Tenant};
class TaskCollectionsSeeder extends Seeder
{
@@ -13,78 +12,69 @@ class TaskCollectionsSeeder extends Seeder
*/
public function run(): void
{
// Get demo tenant
$demoTenant = Tenant::where('slug', 'demo')->first();
if (!$demoTenant) {
$this->command->info('Demo tenant not found, skipping task collections seeding');
return;
}
// Get demo event ID
$demoEventId = DB::table('events')->where('slug', 'demo-wedding-2025')->value('id');
if (!$demoEventId) {
$demoEvent = Event::where('slug', 'demo-wedding-2025')->first();
if (!$demoEvent) {
$this->command->info('Demo event not found, skipping task collections seeding');
return;
}
// Get some task IDs for demo (assuming TasksSeeder was run)
$taskIds = DB::table('tasks')->limit(6)->pluck('id')->toArray();
$taskIds = Task::where('tenant_id', $demoTenant->id)->limit(6)->get('id')->pluck('id')->toArray();
if (empty($taskIds)) {
$this->command->info('No tasks found, skipping task collections seeding');
return;
}
// Create Wedding Task Collection
$weddingCollectionId = DB::table('task_collections')->insertGetId([
'name' => json_encode([
// Create Wedding Task Collection using Eloquent
$weddingCollection = TaskCollection::create([
'tenant_id' => $demoTenant->id,
'name' => [
'de' => 'Hochzeitsaufgaben',
'en' => 'Wedding Tasks'
]),
'description' => json_encode([
],
'description' => [
'de' => 'Spezielle Aufgaben für Hochzeitsgäste',
'en' => 'Special tasks for wedding guests'
]),
],
]);
// Assign first 4 tasks to wedding collection
$weddingTasks = array_slice($taskIds, 0, 4);
foreach ($weddingTasks as $taskId) {
DB::table('task_collection_task')->insert([
'task_collection_id' => $weddingCollectionId,
'task_id' => $taskId,
]);
}
// Assign first 4 tasks to wedding collection using Eloquent
$weddingTasks = collect($taskIds)->take(4);
$weddingCollection->tasks()->attach($weddingTasks);
// Link wedding collection to demo event
DB::table('event_task_collection')->insert([
'event_id' => $demoEventId,
'task_collection_id' => $weddingCollectionId,
'sort_order' => 1,
]);
// Link wedding collection to demo event using Eloquent
$demoEvent->taskCollections()->attach($weddingCollection, ['sort_order' => 1]);
// Create General Fun Tasks Collection (fallback)
$funCollectionId = DB::table('task_collections')->insertGetId([
'name' => json_encode([
// Create General Fun Tasks Collection (fallback) using Eloquent
$funCollection = TaskCollection::create([
'tenant_id' => $demoTenant->id,
'name' => [
'de' => 'Spaß-Aufgaben',
'en' => 'Fun Tasks'
]),
'description' => json_encode([
],
'description' => [
'de' => 'Allgemeine unterhaltsame Aufgaben',
'en' => 'General entertaining tasks'
]),
],
]);
// Assign remaining tasks to fun collection
$funTasks = array_slice($taskIds, 4);
foreach ($funTasks as $taskId) {
DB::table('task_collection_task')->insert([
'task_collection_id' => $funCollectionId,
'task_id' => $taskId,
]);
}
// Assign remaining tasks to fun collection using Eloquent
$funTasks = collect($taskIds)->slice(4);
$funCollection->tasks()->attach($funTasks);
// Link fun collection to demo event as fallback
DB::table('event_task_collection')->insert([
'event_id' => $demoEventId,
'task_collection_id' => $funCollectionId,
'sort_order' => 2,
]);
// Link fun collection to demo event as fallback using Eloquent
$demoEvent->taskCollections()->attach($funCollection, ['sort_order' => 2]);
$this->command->info("✅ Created 2 task collections with " . count($taskIds) . " tasks for demo event");
$this->command->info("Wedding Collection ID: {$weddingCollectionId}");
$this->command->info("Fun Collection ID: {$funCollectionId}");
$this->command->info("Wedding Collection ID: {$weddingCollection->id}");
$this->command->info("Fun Collection ID: {$funCollection->id}");
}
}