feat(categories): add category retrieval and pagination for tenant-specific products

This commit is contained in:
2026-07-28 12:20:17 -03:00
parent ff9d7728e8
commit 8dc80411d7
14 changed files with 355 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ use App\Domains\Catalog\Enums\GroupLayout;
use App\Domains\Catalog\Enums\ProductLayout;
use App\Domains\Catalog\Models\Attribute;
use App\Domains\Catalog\Models\CatalogItem;
use App\Domains\Catalog\Models\Category;
use App\Domains\Catalog\Models\FeaturedGroup;
use App\Domains\Catalog\Models\Inventory;
use App\Domains\Tenant\Models\Tenant;
@@ -155,6 +156,24 @@ class FiestaFutbolInfantilProductSeederTest extends TestCase
);
$this->assertSame(9, CatalogItem::query()->where('tenant_code', $tenant->codigo)->count());
$this->assertSame(10, Inventory::query()->count());
$this->assertSame(
['Entradas', 'Estacionamiento', 'Gastronomía'],
Category::query()
->where('tenant_code', $tenant->codigo)
->orderBy('nombre')
->pluck('nombre')
->all(),
);
$this->assertSame(
'Estacionamiento',
CatalogItem::query()
->where('tenant_code', $tenant->codigo)
->where('slug', 'estacionamiento-auto')
->with('category')
->sole()
->category
->nombre,
);
$featuredGroups = FeaturedGroup::query()
->where('tenant_code', $tenant->codigo)

View File

@@ -7,6 +7,7 @@ use App\Domains\Attachable\Models\Attachment;
use App\Domains\Catalog\Enums\GroupLayout;
use App\Domains\Catalog\Enums\ProductLayout;
use App\Domains\Catalog\Models\CatalogItem;
use App\Domains\Catalog\Models\Category;
use App\Domains\Catalog\Models\FeaturedGroup;
use App\Domains\Tenant\Models\Tenant;
use Database\Seeders\AttributeSeeder;
@@ -91,5 +92,19 @@ class ProductCatalogFromImagesSeederTest extends TestCase
->pluck('catalog_item_id')
->diff($catalogItemIds),
);
$this->assertSame(
['Accesorios', 'Buzos', 'Pantalones', 'Remeras', 'Zapatillas'],
Category::query()
->where('tenant_code', $tenant->codigo)
->orderBy('nombre')
->pluck('nombre')
->all(),
);
$this->assertFalse(
CatalogItem::query()
->where('tenant_code', $tenant->codigo)
->whereHas('category', fn ($query) => $query->where('tenant_code', '!=', $tenant->codigo))
->exists(),
);
}
}