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:
97
database/seeders/DemoPhotosSeeder.php
Normal file
97
database/seeders/DemoPhotosSeeder.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\{Event, Task, Emotion, Photo, PhotoLike, Tenant};
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class DemoPhotosSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// Get demo event and tenant
|
||||
$demoEvent = Event::where('slug', 'demo-wedding-2025')->first();
|
||||
$demoTenant = Tenant::where('slug', 'demo')->first();
|
||||
|
||||
if (!$demoEvent || !$demoTenant) {
|
||||
$this->command->info('Demo event or tenant not found, skipping DemoPhotosSeeder');
|
||||
return;
|
||||
}
|
||||
|
||||
// Get all available tasks and emotions
|
||||
$tasks = Task::where('tenant_id', $demoTenant->id)->get();
|
||||
$emotions = Emotion::all();
|
||||
|
||||
if ($tasks->isEmpty() || $emotions->isEmpty()) {
|
||||
$this->command->info('No tasks or emotions found, skipping DemoPhotosSeeder');
|
||||
return;
|
||||
}
|
||||
|
||||
// List of 20 German guest names
|
||||
$guestNames = [
|
||||
'Anna Müller', 'Max Schmidt', 'Lisa Weber', 'Tom Fischer', 'Sophie Bauer',
|
||||
'Lukas Hoffmann', 'Emma Wagner', 'Jonas Klein', 'Mia Schwarz', 'Felix Becker',
|
||||
'Lena Richter', 'Paul Lehmann', 'Julia Neumann', 'David Vogel', 'Sara Krüger',
|
||||
'Tim Berger', 'Nina Wolf', 'Ben Schäfer', 'Laura Stein', 'Moritz Fuchs'
|
||||
];
|
||||
|
||||
// Get all photo files from storage
|
||||
$photoDir = storage_path('app/public/photos');
|
||||
$photoFiles = File::files($photoDir);
|
||||
|
||||
$seededCount = 0;
|
||||
foreach ($photoFiles as $file) {
|
||||
$filename = $file->getFilename();
|
||||
if (!str_ends_with($filename, '.jpg')) continue;
|
||||
|
||||
// Check if already seeded (avoid duplicates)
|
||||
if (Photo::where('file_path', 'photos/' . $filename)->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Generate thumbnail path
|
||||
$thumbnailFilename = str_replace('.jpg', '_thumb.jpg', $filename);
|
||||
$thumbnailPath = 'thumbnails/' . $thumbnailFilename;
|
||||
|
||||
// Random assignments
|
||||
$randomTask = $tasks->random();
|
||||
$randomEmotion = $emotions->random();
|
||||
$randomUploader = $guestNames[array_rand($guestNames)];
|
||||
$randomLikes = rand(0, 20);
|
||||
$eventDate = $demoEvent->date;
|
||||
$randomUploadedAt = Carbon::parse($eventDate)->addHours(rand(0, 24))->addMinutes(rand(0, 59));
|
||||
|
||||
// Create photo
|
||||
$photo = Photo::create([
|
||||
'tenant_id' => $demoTenant->id, // Assuming tenant_id exists
|
||||
'event_id' => $demoEvent->id,
|
||||
'task_id' => $randomTask->id,
|
||||
'emotion_id' => $randomEmotion->id,
|
||||
'file_path' => 'photos/' . $filename,
|
||||
'thumbnail_path' => $thumbnailPath,
|
||||
'uploader_name' => $randomUploader,
|
||||
'uploaded_at' => $randomUploadedAt,
|
||||
'is_featured' => false,
|
||||
'metadata' => [],
|
||||
]);
|
||||
|
||||
// Add random likes
|
||||
if ($randomLikes > 0) {
|
||||
for ($i = 0; $i < $randomLikes; $i++) {
|
||||
PhotoLike::create([
|
||||
'photo_id' => $photo->id,
|
||||
'session_id' => 'demo_session_' . Str::random(10), // Anonymous session
|
||||
'created_at' => $randomUploadedAt->clone()->addMinutes(rand(0, 60)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$seededCount++;
|
||||
}
|
||||
|
||||
$this->command->info("✅ Seeded {$seededCount} demo photos with random tasks, emotions, uploaders, and likes");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user