feat: Introduce source type for featured groups; add category association and implement FeaturedGroupService for item sourcing

This commit is contained in:
2026-08-04 13:17:00 -03:00
parent 8aa3a26ee7
commit 84e45bb964
13 changed files with 260 additions and 136 deletions

View File

@@ -5,6 +5,7 @@ namespace Tests\Unit\Catalog;
use App\Domains\Attachable\Models\Attachment;
use App\Domains\Catalog\Enums\CatalogItemType;
use App\Domains\Catalog\Enums\EventProductType;
use App\Domains\Catalog\Enums\FeaturedGroupSource;
use App\Domains\Catalog\Enums\GroupLayout;
use App\Domains\Catalog\Enums\InventoryPolicy;
use App\Domains\Catalog\Enums\ProductLayout;
@@ -104,6 +105,8 @@ class CatalogModelsTest extends TestCase
{
$group = new FeaturedGroup;
$group->setRawAttributes([
'source_type' => FeaturedGroupSource::Category->value,
'category_id' => '4',
'product_layout' => ProductLayout::ColumnWithImage->value,
'group_layout' => GroupLayout::SimpleVertical->value,
'group_order' => '2',
@@ -118,9 +121,12 @@ class CatalogModelsTest extends TestCase
$this->assertSame('featured_groups', $group->getTable());
$this->assertFalse($group->usesTimestamps());
$this->assertSame(ProductLayout::ColumnWithImage, $group->product_layout);
$this->assertSame(FeaturedGroupSource::Category, $group->source_type);
$this->assertSame(4, $group->category_id);
$this->assertSame(GroupLayout::SimpleVertical, $group->group_layout);
$this->assertSame(2, $group->group_order);
$this->assertInstanceOf(Tenant::class, $group->tenant()->getRelated());
$this->assertInstanceOf(Category::class, $group->category()->getRelated());
$this->assertInstanceOf(FeaturedItem::class, $group->featuredItems()->getRelated());
$this->assertSame('featured_items', $featuredItem->getTable());