feat: Introduce client management and integration updates

- Added client_id field to StoreTenantRequest and UpdateTenantRequest for tenant management.
- Updated TenantResource to include client_id in the response.
- Created migration to establish clients table and link tenants to clients.
- Migrated existing tenant integrations to client_integrations table.
- Grouped specific tenants under a shared client (OnTicket) in a new migration.
- Updated seeders to reflect new client structure and relationships.
- Adjusted integration configurations to require client instead of tenant.
- Added tests for client integration functionality and ensured existing tests reflect the new client structure.
This commit is contained in:
2026-08-18 16:18:34 -03:00
parent e6785eb5af
commit d73b4d1daf
42 changed files with 931 additions and 392 deletions

View File

@@ -11,6 +11,7 @@ use App\Domains\Catalog\Models\Attribute;
use App\Domains\Catalog\Models\CatalogItem;
use App\Domains\Catalog\Models\FeaturedGroup;
use App\Domains\Catalog\Services\CatalogService;
use App\Domains\Client\Models\Client;
use App\Domains\Tenant\Models\Tenant;
use App\Domains\Tenant\Services\TenantService;
use Illuminate\Database\Seeder;
@@ -20,6 +21,8 @@ use RuntimeException;
class DesfilePuraTendenciaSeeder extends Seeder
{
private const ONTICKET_CLIENT_CODE = 'onticket';
private const TENANT_CODE = 'desfile_pura_tendencia';
public function __construct(
@@ -29,20 +32,30 @@ class DesfilePuraTendenciaSeeder extends Seeder
public function run(): void
{
if (Tenant::query()->where('codigo', self::TENANT_CODE)->exists()) {
$client = Client::query()->firstOrCreate(
['code' => self::ONTICKET_CLIENT_CODE],
['name' => 'OnTicket'],
);
$tenant = Tenant::query()->where('codigo', self::TENANT_CODE)->first();
if ($tenant) {
$tenant->update(['client_id' => $client->id]);
return;
}
DB::transaction(function (): void {
$this->createTenant();
DB::transaction(function () use ($client): void {
$this->createTenant($client);
$this->createEventDate();
$this->createEntryCatalog();
});
}
private function createTenant(): void
private function createTenant(Client $client): void
{
$this->tenantService->create([
'client_id' => $client->id,
'codigo' => self::TENANT_CODE,
'nombre' => 'Desfile Pura Tendencia',
'dominio' => 'desfile-pura-tendencia.localhost',