Merge branch 'refactor/inventory_stock' of https://gitea.quo.ar/tbianchini/shopit-back into refactor/inventory_stock

This commit is contained in:
2026-09-29 08:23:09 -03:00
parent c5aeb19735
commit 96378a6c2e
596 changed files with 239 additions and 7622 deletions

View File

@@ -3,9 +3,8 @@
namespace App\Shared\Integration\Services;
use App\Domains\Core\Client\Models\Client;
use App\Domains\Core\Tenant\Models\AdminWebsiteType;
use App\Domains\Core\Tenant\Models\Tenant;
use App\Domains\Ticketing\Event\Models\Event;
use App\Domains\Core\Tenant\Models\AdminWebsiteType;
use Exception;
use Illuminate\Contracts\Mail\Factory as MailFactory;
use Illuminate\Contracts\Mail\Mailer;
@@ -40,7 +39,14 @@ class MailService extends BaseIntegrationService
public function forTenant(string $tenantCode): self
{
parent::forTenant($tenantCode);
$this->configureMailer();
if ($this->integrationInstance) {
$this->mailer = $this->resolveMailer();
$this->usesInstanceMailer = true;
} else {
$this->mailer = $this->mailFactory->mailer();
$this->usesInstanceMailer = false;
}
return $this;
}
@@ -49,30 +55,16 @@ class MailService extends BaseIntegrationService
{
parent::forClient($client);
$this->tenant = $this->clientContext?->tenants()->first();
$this->configureMailer();
return $this;
}
public function forEvent(Event $event): self
{
parent::forEvent($event);
$this->configureMailer();
return $this;
}
private function configureMailer(): void
{
if ($this->integrationInstance) {
$this->mailer = $this->resolveMailer();
$this->usesInstanceMailer = true;
return;
} else {
$this->mailer = $this->mailFactory->mailer();
$this->usesInstanceMailer = false;
}
$this->mailer = $this->mailFactory->mailer();
$this->usesInstanceMailer = false;
return $this;
}
public function getHeaders(): array
@@ -91,7 +83,7 @@ class MailService extends BaseIntegrationService
array $attachments = [],
): void {
if (! $this->mailer || ! $this->tenant) {
throw new Exception('MailService no está configurado. Llamá a forTenant(), forClient() o forEvent() primero.');
throw new Exception('MailService no está configurado. Llamá a forTenant() o forClient() primero.');
}
$brand ??= $this->tenant;
@@ -168,7 +160,7 @@ class MailService extends BaseIntegrationService
public function onSetup(): void
{
if (! $this->mailer || ! $this->clientContext) {
throw new Exception('MailService no está configurado. Llamá a forTenant(), forClient() o forEvent() primero.');
throw new Exception('MailService no está configurado. Llamá a forTenant() o forClient() primero.');
}
$recipient = $this->getIntegrationSetting('MAIL_FROM_ADDRESS');