feat(tenant): update validation rules for logos and main carousel images, enhance tests for carousel image upload and update

This commit is contained in:
2026-07-23 14:20:26 -03:00
parent 67ede1a2b4
commit c31be9c927
4 changed files with 103 additions and 20 deletions

View File

@@ -12,15 +12,12 @@ use Illuminate\Validation\ValidationException;
class TenantService
{
public function __construct(protected AttachmentService $attachmentService)
{
}
public function __construct(protected AttachmentService $attachmentService) {}
/**
* Create a new tenant and store its logos.
*
* @param array<string, mixed> $data
* @return Tenant
*/
public function create(array $data): Tenant
{
@@ -40,7 +37,7 @@ class TenantService
$headerAttachmentId = null;
if ($headerLogo) {
$attachment = Str::isUuid($headerLogo)
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $headerLogo)->first()
? Attachment::query()->where('key', $headerLogo)->first()
: $this->attachmentService->store($headerLogo, 'tenants');
if ($attachment) {
@@ -51,7 +48,7 @@ class TenantService
$footerAttachmentId = null;
if ($footerLogo) {
$attachment = Str::isUuid($footerLogo)
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $footerLogo)->first()
? Attachment::query()->where('key', $footerLogo)->first()
: $this->attachmentService->store($footerLogo, 'tenants');
if ($attachment) {
@@ -64,7 +61,7 @@ class TenantService
if ($heroBgImage) {
$attachment = Str::isUuid($heroBgImage)
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $heroBgImage)->first()
? Attachment::query()->where('key', $heroBgImage)->first()
: $this->attachmentService->store($heroBgImage, 'tenants');
if ($attachment) {
@@ -85,9 +82,7 @@ class TenantService
/**
* Update an existing tenant and store new logos if uploaded.
*
* @param Tenant $tenant
* @param array<string, mixed> $data
* @return Tenant
*/
public function update(Tenant $tenant, array $data): Tenant
{
@@ -115,7 +110,7 @@ class TenantService
if ($hasHeaderLogoKey) {
if ($headerLogo) {
$attachment = Str::isUuid($headerLogo)
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $headerLogo)->first()
? Attachment::query()->where('key', $headerLogo)->first()
: $this->attachmentService->store($headerLogo, 'tenants');
if ($attachment) {
@@ -131,7 +126,7 @@ class TenantService
if ($hasFooterLogoKey) {
if ($footerLogo) {
$attachment = Str::isUuid($footerLogo)
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $footerLogo)->first()
? Attachment::query()->where('key', $footerLogo)->first()
: $this->attachmentService->store($footerLogo, 'tenants');
if ($attachment) {
@@ -148,7 +143,7 @@ class TenantService
if ($hasHeroBgImageKey) {
if ($heroBgImage) {
$attachment = Str::isUuid($heroBgImage)
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $heroBgImage)->first()
? Attachment::query()->where('key', $heroBgImage)->first()
: $this->attachmentService->store($heroBgImage, 'tenants');
if ($attachment) {