Fix guest demo UX and enforce guest limits
This commit is contained in:
@@ -11,6 +11,7 @@ use App\Models\Tenant;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -98,7 +99,7 @@ class DemoPhotosSeeder extends Seeder
|
||||
}
|
||||
|
||||
$guestNames = $config['guest_names'];
|
||||
$photosToSeed = min($photoFiles->count(), count($guestNames));
|
||||
$photosToSeed = min($photoFiles->count(), count($guestNames), 20);
|
||||
|
||||
if ($photosToSeed === 0) {
|
||||
continue;
|
||||
@@ -143,23 +144,29 @@ class DemoPhotosSeeder extends Seeder
|
||||
$taskId = $taskIds ? $taskIds[array_rand($taskIds)] : null;
|
||||
$emotionId = $emotions->random()->id;
|
||||
|
||||
$photoData = [
|
||||
'task_id' => $taskId,
|
||||
'emotion_id' => $emotionId,
|
||||
'guest_name' => $guestName,
|
||||
'thumbnail_path' => $thumbDest,
|
||||
'likes_count' => $likes,
|
||||
'is_featured' => $i === 0,
|
||||
'metadata' => ['demo' => true],
|
||||
'created_at' => $timestamp,
|
||||
'updated_at' => $timestamp,
|
||||
];
|
||||
|
||||
if (Schema::hasColumn('photos', 'status')) {
|
||||
$photoData['status'] = 'approved';
|
||||
}
|
||||
|
||||
$photo = Photo::updateOrCreate(
|
||||
[
|
||||
'tenant_id' => $tenant->id,
|
||||
'event_id' => $event->id,
|
||||
'file_path' => $destPath,
|
||||
],
|
||||
[
|
||||
'task_id' => $taskId,
|
||||
'emotion_id' => $emotionId,
|
||||
'guest_name' => $guestName,
|
||||
'thumbnail_path' => $thumbDest,
|
||||
'likes_count' => $likes,
|
||||
'is_featured' => $i === 0,
|
||||
'metadata' => ['demo' => true],
|
||||
'created_at' => $timestamp,
|
||||
'updated_at' => $timestamp,
|
||||
]
|
||||
$photoData
|
||||
);
|
||||
|
||||
PhotoLike::where('photo_id', $photo->id)->delete();
|
||||
|
||||
Reference in New Issue
Block a user