feat(seeder): add FiestaTradicionArrufoSeeder to tenant provisioning and update OnTicketTenantSeeder for image validation
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Domains\Commerce\Catalog\Enums\InventoryPolicy;
|
||||
use App\Domains\Commerce\Catalog\Models\CatalogItem;
|
||||
use App\Domains\Commerce\Catalog\Models\Attribute;
|
||||
use App\Domains\Commerce\Catalog\Models\CatalogItem;
|
||||
use App\Domains\Commerce\Catalog\Services\CatalogService;
|
||||
use App\Domains\Core\Tenant\Models\Tenant;
|
||||
use App\Domains\Ticketing\Event\Models\Event;
|
||||
@@ -13,6 +13,7 @@ use App\Shared\Enums\FieldType;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use RuntimeException;
|
||||
|
||||
class FiestaTradicionArrufoSeeder extends Seeder
|
||||
@@ -51,7 +52,8 @@ class FiestaTradicionArrufoSeeder extends Seeder
|
||||
'location' => 'Predio de Doma del Club Unión Deportiva Arrufó',
|
||||
]);
|
||||
|
||||
if ($event->attachment_id === null) {
|
||||
$eventImage = $event->attachment;
|
||||
if ($eventImage === null || ! Storage::disk('s3')->exists($eventImage->path)) {
|
||||
$event->update(['attachment_id' => $this->attachments->store($this->image(), 'events')->id]);
|
||||
}
|
||||
|
||||
@@ -85,6 +87,7 @@ class FiestaTradicionArrufoSeeder extends Seeder
|
||||
$existing = CatalogItem::query()->where('tenant_code', $tenant->codigo)->where('slug', $data['slug'])->first();
|
||||
if ($existing !== null) {
|
||||
$existing->update(['sales_end_at' => $data['sales_end_at'] ?? null]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Domains\Core\Tenant\Services\TenantProvisioningService;
|
||||
use App\Domains\Core\Tenant\Services\WebsiteExtraService;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use RuntimeException;
|
||||
|
||||
class OnTicketTenantSeeder extends Seeder
|
||||
@@ -58,10 +59,22 @@ class OnTicketTenantSeeder extends Seeder
|
||||
'display_seach_bar' => true,
|
||||
]);
|
||||
|
||||
if ($tenant->header_bg_image_id === null) {
|
||||
$tenant = $this->tenantProvisioningService->update($tenant, [
|
||||
'header_bg_image' => $this->uploadedImage('onticket_header_background.png'),
|
||||
]);
|
||||
$missingImages = [];
|
||||
foreach ([
|
||||
'header_logo' => ['relation' => 'headerLogo', 'filename' => 'onticket_logo.png'],
|
||||
'footer_logo' => ['relation' => 'footerLogo', 'filename' => 'onticket_footer_logo.png'],
|
||||
'favicon' => ['relation' => 'favicon', 'filename' => 'onticket_favicon.svg'],
|
||||
'header_bg_image' => ['relation' => 'headerBackgroundImage', 'filename' => 'onticket_header_background.png'],
|
||||
] as $field => $image) {
|
||||
$attachment = $tenant->{$image['relation']};
|
||||
|
||||
if ($attachment === null || ! Storage::disk('s3')->exists($attachment->path)) {
|
||||
$missingImages[$field] = $this->uploadedImage($image['filename']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($missingImages !== []) {
|
||||
$tenant = $this->tenantProvisioningService->update($tenant, $missingImages);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user