feat: implement tenant management system with attachment support and bootstrap controller
This commit is contained in:
@@ -31,15 +31,25 @@ class TenantService
|
||||
$tenant = Tenant::query()->create($data);
|
||||
|
||||
if ($headerLogo) {
|
||||
$attachment = $this->attachmentService->store($headerLogo, 'tenants');
|
||||
$tenant->header_logo = $attachment->key;
|
||||
$tenant->attachments()->attach($attachment->id);
|
||||
$attachment = Str::isUuid($headerLogo)
|
||||
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $headerLogo)->first()
|
||||
: $this->attachmentService->store($headerLogo, 'tenants');
|
||||
|
||||
if ($attachment) {
|
||||
$tenant->header_logo_id = $attachment->id;
|
||||
$tenant->attachments()->attach($attachment->id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($footerLogo) {
|
||||
$attachment = $this->attachmentService->store($footerLogo, 'tenants');
|
||||
$tenant->footer_logo = $attachment->key;
|
||||
$tenant->attachments()->attach($attachment->id);
|
||||
$attachment = Str::isUuid($footerLogo)
|
||||
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $footerLogo)->first()
|
||||
: $this->attachmentService->store($footerLogo, 'tenants');
|
||||
|
||||
if ($attachment) {
|
||||
$tenant->footer_logo_id = $attachment->id;
|
||||
$tenant->attachments()->attach($attachment->id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($headerLogo || $footerLogo) {
|
||||
@@ -71,29 +81,35 @@ class TenantService
|
||||
|
||||
if ($hasHeaderLogoKey) {
|
||||
if ($headerLogo) {
|
||||
if (! Str::isUuid($headerLogo)) {
|
||||
$attachment = $this->attachmentService->store($headerLogo, 'tenants');
|
||||
$tenant->header_logo = $attachment->key;
|
||||
$attachment = Str::isUuid($headerLogo)
|
||||
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $headerLogo)->first()
|
||||
: $this->attachmentService->store($headerLogo, 'tenants');
|
||||
|
||||
if ($attachment) {
|
||||
$tenant->header_logo_id = $attachment->id;
|
||||
$tenant->attachments()->attach($attachment->id);
|
||||
} else {
|
||||
$tenant->header_logo = $headerLogo;
|
||||
$tenant->header_logo_id = null;
|
||||
}
|
||||
} else {
|
||||
$tenant->header_logo = null;
|
||||
$tenant->header_logo_id = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasFooterLogoKey) {
|
||||
if ($footerLogo) {
|
||||
if (! Str::isUuid($footerLogo)) {
|
||||
$attachment = $this->attachmentService->store($footerLogo, 'tenants');
|
||||
$tenant->footer_logo = $attachment->key;
|
||||
$attachment = Str::isUuid($footerLogo)
|
||||
? \App\Domains\Attachable\Models\Attachment::query()->where('key', $footerLogo)->first()
|
||||
: $this->attachmentService->store($footerLogo, 'tenants');
|
||||
|
||||
if ($attachment) {
|
||||
$tenant->footer_logo_id = $attachment->id;
|
||||
$tenant->attachments()->attach($attachment->id);
|
||||
} else {
|
||||
$tenant->footer_logo = $footerLogo;
|
||||
$tenant->footer_logo_id = null;
|
||||
}
|
||||
} else {
|
||||
$tenant->footer_logo = null;
|
||||
$tenant->footer_logo_id = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user