feat: implement full CRUD support and database schema for multi-tenant architecture

This commit is contained in:
2026-06-26 16:57:59 -03:00
parent 8708cea122
commit 31b65eb676
10 changed files with 562 additions and 58 deletions

View File

@@ -12,11 +12,7 @@ class ProductAttributeControllerTest extends TestCase
public function test_it_creates_a_select_attribute_with_options(): void
{
Tenant::create([
'codigo' => 'acme',
'nombre' => 'Acme',
'dominio' => 'acme.com',
]);
$this->createTenant('acme', 'Acme', 'acme.com');
$response = $this->postJson('/api/tenants/acme/product-attributes', [
'codigo' => 'color',
@@ -62,11 +58,7 @@ class ProductAttributeControllerTest extends TestCase
public function test_it_rejects_options_for_string_attributes(): void
{
Tenant::create([
'codigo' => 'acme',
'nombre' => 'Acme',
'dominio' => 'acme.com',
]);
$this->createTenant('acme', 'Acme', 'acme.com');
$response = $this->postJson('/api/tenants/acme/product-attributes', [
'codigo' => 'material',
@@ -81,4 +73,37 @@ class ProductAttributeControllerTest extends TestCase
->assertUnprocessable()
->assertJsonValidationErrors(['options']);
}
protected function createTenant(string $codigo, string $nombre, string $dominio): Tenant
{
$hdrKey = (string) \Illuminate\Support\Str::uuid();
$ftrKey = (string) \Illuminate\Support\Str::uuid();
$headerAttachment = \App\Domains\Attachable\Models\Attachment::create([
'key' => $hdrKey,
'path' => 'tenants/' . $hdrKey . '.png',
'filename' => 'logo_header.png',
'type' => \App\Domains\Attachable\Enums\AttachmentType::Image,
'mime_type' => 'image/png',
]);
$footerAttachment = \App\Domains\Attachable\Models\Attachment::create([
'key' => $ftrKey,
'path' => 'tenants/' . $ftrKey . '.png',
'filename' => 'logo_footer.png',
'type' => \App\Domains\Attachable\Enums\AttachmentType::Image,
'mime_type' => 'image/png',
]);
return Tenant::create([
'codigo' => $codigo,
'nombre' => $nombre,
'dominio' => $dominio,
'primary_color' => '#111111',
'secondary_color' => '#222222',
'danger_color' => '#333333',
'header_footer_bg_color' => '#444444',
'header_logo_id' => $headerAttachment->id,
'footer_logo_id' => $footerAttachment->id,
]);
}
}