refactor(tenant): introduce TenantInformationService for loading tenant data and resolving website extras
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Domains\Attachable\Models\Attachment;
|
||||
use App\Domains\Attachable\Services\AttachmentService;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use App\Domains\Tenant\Services\TenantService;
|
||||
@@ -58,6 +59,35 @@ class TenantSeeder extends Seeder
|
||||
'header_logo' => $this->uploadedImage('images/sonder_header.png', 'sonder_header.png'),
|
||||
'footer_logo' => $this->uploadedImage('images/sonder_footer.png', 'sonder_footer.png'),
|
||||
'social_media' => self::SOCIAL_MEDIA,
|
||||
'website_type_code' => 'shopit',
|
||||
'extras' => [
|
||||
'carousel' => [
|
||||
$this->uploadedImage(
|
||||
'images/sonder-main-carousel/01-urban-team.png',
|
||||
'01-urban-team.png',
|
||||
),
|
||||
$this->uploadedImage(
|
||||
'images/sonder-main-carousel/02-running-shoes.png',
|
||||
'02-running-shoes.png',
|
||||
),
|
||||
$this->uploadedImage(
|
||||
'images/sonder-main-carousel/03-streetwear.png',
|
||||
'03-streetwear.png',
|
||||
),
|
||||
$this->uploadedImage(
|
||||
'images/sonder-main-carousel/04-football-training.png',
|
||||
'04-football-training.png',
|
||||
),
|
||||
$this->uploadedImage(
|
||||
'images/sonder-main-carousel/05-activewear-essentials.png',
|
||||
'05-activewear-essentials.png',
|
||||
),
|
||||
$this->uploadedImage(
|
||||
'images/sonder-main-carousel/06-city-runners.png',
|
||||
'06-city-runners.png',
|
||||
),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->deleteTenant('fiesta_futbol_infantil');
|
||||
@@ -86,6 +116,27 @@ class TenantSeeder extends Seeder
|
||||
'futbol_infantil_footer.png',
|
||||
),
|
||||
'social_media' => self::SOCIAL_MEDIA,
|
||||
'website_type_code' => 'onticket',
|
||||
'extras' => [
|
||||
'heroConfig' => [
|
||||
'title_html' => '<h1>Fiesta Fútbol Infantil</h1>',
|
||||
'description_html' => '<p>Viví una jornada inolvidable de fútbol infantil.</p>',
|
||||
'button_text' => 'Comprar entradas',
|
||||
'button_href' => '/tickets',
|
||||
'background_image_id' => $this->uploadedImage(
|
||||
'images/futbol_infantil_hero.jpg',
|
||||
'futbol_infantil_hero.jpg',
|
||||
),
|
||||
],
|
||||
'eventConfig' => [
|
||||
'title' => 'Fiesta Fútbol Infantil',
|
||||
'location' => 'Rosario, Santa Fe',
|
||||
'dates' => [
|
||||
'2026-12-05',
|
||||
'2026-12-06',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -101,6 +152,24 @@ class TenantSeeder extends Seeder
|
||||
|
||||
$attachmentService = app(AttachmentService::class);
|
||||
|
||||
$extraAttachments = Attachment::query()
|
||||
->where('path', 'like', 'tenants/%/extras/%')
|
||||
->get()
|
||||
->filter(
|
||||
fn (Attachment $attachment): bool => str_starts_with(
|
||||
$attachment->path,
|
||||
"tenants/{$codigo}/extras/"
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($extraAttachments as $attachment) {
|
||||
try {
|
||||
$attachmentService->delete($attachment);
|
||||
} catch (Throwable) {
|
||||
// Ignore cleanup errors while recreating demo data.
|
||||
}
|
||||
}
|
||||
|
||||
if ($tenant->headerLogo) {
|
||||
try {
|
||||
$attachmentService->delete($tenant->headerLogo);
|
||||
@@ -128,10 +197,17 @@ class TenantSeeder extends Seeder
|
||||
throw new RuntimeException("Image not found at path: {$path}");
|
||||
}
|
||||
|
||||
$mimeType = match (strtolower(pathinfo($filename, PATHINFO_EXTENSION))) {
|
||||
'jpg', 'jpeg' => 'image/jpeg',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
default => 'image/png',
|
||||
};
|
||||
|
||||
return new UploadedFile(
|
||||
$path,
|
||||
$filename,
|
||||
'image/png',
|
||||
$mimeType,
|
||||
null,
|
||||
true,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user