feat(tenant): add hero carousel images and update related services and tests
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Domains\Client\Models\Client;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use App\Domains\Tenant\Models\AdminWebsiteType;
|
||||
use App\Domains\Tenant\Services\TenantService;
|
||||
use App\Domains\Tenant\Services\WebsiteExtraService;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use RuntimeException;
|
||||
@@ -19,6 +20,17 @@ class TenantSeeder extends Seeder
|
||||
|
||||
private const SONDER_CLIENT_CODE = 'sonder';
|
||||
|
||||
private const ONTICKET_HERO_CAROUSEL_IMAGES = [
|
||||
'onticket_hero_carousel_1.png',
|
||||
'onticket_hero_carousel_2.png',
|
||||
'onticket_hero_carousel_3.avif',
|
||||
'onticket_hero_carousel_4.jfif',
|
||||
'onticket_hero_carousel_5.jfif',
|
||||
'onticket_hero_carousel_6.jfif',
|
||||
'onticket_hero_carousel_7.avif',
|
||||
'onticket_hero_carousel_8.avif',
|
||||
];
|
||||
|
||||
private const SOCIAL_MEDIA = [
|
||||
[
|
||||
'code' => 'instagram',
|
||||
@@ -42,7 +54,10 @@ class TenantSeeder extends Seeder
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct(protected TenantService $tenantService) {}
|
||||
public function __construct(
|
||||
protected TenantService $tenantService,
|
||||
protected WebsiteExtraService $websiteExtraService,
|
||||
) {}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
@@ -107,6 +122,25 @@ class TenantSeeder extends Seeder
|
||||
$onTicketTenant->update(['storefront_website_type_code' => 'onticket_multi_event']);
|
||||
}
|
||||
|
||||
$onTicketTenant = Tenant::query()->where('codigo', 'onticket')->firstOrFail();
|
||||
|
||||
if (
|
||||
$onTicketTenant->storefront_website_type_code === 'onticket_multi_event'
|
||||
&& ! $onTicketTenant->websiteExtras()->whereHas('websiteTypeExtra', fn ($query) => $query->where('codigo', 'heroCarousel'))->exists()
|
||||
) {
|
||||
$this->websiteExtraService->updateForTenant(
|
||||
$onTicketTenant,
|
||||
'heroCarousel',
|
||||
array_map(
|
||||
fn (string $filename): UploadedFile => $this->uploadedImage(
|
||||
"images/tennants/onticket/onticket_tennant_hero_carousel/{$filename}",
|
||||
$filename,
|
||||
),
|
||||
self::ONTICKET_HERO_CAROUSEL_IMAGES,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$this->deleteTenant('sonder');
|
||||
|
||||
Tenant::query()
|
||||
@@ -333,7 +367,8 @@ class TenantSeeder extends Seeder
|
||||
}
|
||||
|
||||
$mimeType = match (strtolower(pathinfo($filename, PATHINFO_EXTENSION))) {
|
||||
'jpg', 'jpeg' => 'image/jpeg',
|
||||
'jpg', 'jpeg', 'jfif' => 'image/jpeg',
|
||||
'avif' => 'image/avif',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
'svg' => 'image/svg+xml',
|
||||
|
||||
@@ -10,6 +10,19 @@ use RuntimeException;
|
||||
|
||||
class WebsiteTypeSeeder extends Seeder
|
||||
{
|
||||
private const IMAGE_CAROUSEL_SCHEMA = [
|
||||
'request_rules' => [
|
||||
'$' => 'required|array|max:10',
|
||||
'$.*' => 'required|image_or_base64|distinct',
|
||||
],
|
||||
'transforms' => [
|
||||
'$.*' => [
|
||||
'handler' => 'attachment',
|
||||
'attachment_type' => 'image',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
private const PRESENTATION = [
|
||||
'primary_color' => '#FF7006',
|
||||
'secondary_color' => '#777777',
|
||||
@@ -52,18 +65,7 @@ class WebsiteTypeSeeder extends Seeder
|
||||
'nombre' => 'Carrusel principal',
|
||||
'descripcion' => 'Listado de attachments que se muestran en el carousel principal.',
|
||||
'is_required' => false,
|
||||
'config_schema' => [
|
||||
'request_rules' => [
|
||||
'$' => 'required|array|max:10',
|
||||
'$.*' => 'required|image_or_base64|distinct',
|
||||
],
|
||||
'transforms' => [
|
||||
'$.*' => [
|
||||
'handler' => 'attachment',
|
||||
'attachment_type' => 'image',
|
||||
],
|
||||
],
|
||||
],
|
||||
'config_schema' => self::IMAGE_CAROUSEL_SCHEMA,
|
||||
],
|
||||
);
|
||||
|
||||
@@ -86,11 +88,21 @@ class WebsiteTypeSeeder extends Seeder
|
||||
['nombre' => 'OnTicket - evento único', 'header_type' => 'standard'],
|
||||
);
|
||||
|
||||
StorefrontWebsiteType::query()->updateOrCreate(
|
||||
$multiEventStorefront = StorefrontWebsiteType::query()->updateOrCreate(
|
||||
['codigo' => 'onticket_multi_event'],
|
||||
['nombre' => 'OnTicket - múltiples eventos', 'header_type' => 'immersive'],
|
||||
);
|
||||
|
||||
$multiEventStorefront->extras()->updateOrCreate(
|
||||
['codigo' => 'heroCarousel'],
|
||||
[
|
||||
'nombre' => 'Carrusel del hero',
|
||||
'descripcion' => 'Lista ordenada de imágenes del hero.',
|
||||
'is_required' => false,
|
||||
'config_schema' => self::IMAGE_CAROUSEL_SCHEMA,
|
||||
],
|
||||
);
|
||||
|
||||
$onTicketStorefront->extras()->updateOrCreate(
|
||||
['codigo' => 'heroConfig'],
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user