feat(tenant): implement website extras functionality and validation in tenant creation

This commit is contained in:
2026-07-29 15:16:33 -03:00
parent 9e3163b74f
commit 27d4f9fac6
7 changed files with 520 additions and 8 deletions

View File

@@ -10,7 +10,10 @@ use Illuminate\Support\Str;
class TenantService
{
public function __construct(protected AttachmentService $attachmentService) {}
public function __construct(
protected AttachmentService $attachmentService,
protected WebsiteExtraService $websiteExtraService,
) {}
/**
* Create a new tenant and store its logos.
@@ -23,11 +26,13 @@ class TenantService
$headerLogo = $data['header_logo'] ?? null;
$footerLogo = $data['footer_logo'] ?? null;
$socialMedia = $data['social_media'] ?? [];
$extras = $data['extras'] ?? [];
unset(
$data['header_logo'],
$data['footer_logo'],
$data['social_media']
$data['social_media'],
$data['extras'],
);
$headerAttachmentId = null;
@@ -58,6 +63,7 @@ class TenantService
/** @var Tenant $tenant */
$tenant = Tenant::query()->create($data);
$this->syncSocialMedia($tenant, $socialMedia);
$this->websiteExtraService->createForTenant($tenant, $extras);
return $tenant;
});