feat: implement polymorphic relationships for group items to support bundles and product variants

This commit is contained in:
2026-07-17 14:42:44 -03:00
parent 615eacea91
commit cb0fb2899c
10 changed files with 298 additions and 19 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Domains\Catalog\Resources;
use App\Domains\Bundle\Models\Bundle;
use App\Domains\Catalog\Models\ProductVariant;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -12,7 +14,12 @@ class FeaturedVariantResource extends JsonResource
return [
'id' => $this->id,
'featured_group_id' => $this->featured_group_id,
'product_variant_id' => $this->product_variant_id,
'groupable_type' => match ($this->groupable_type) {
ProductVariant::class => 'variant',
Bundle::class => 'bundle',
default => 'unknown',
},
'groupable_id' => $this->groupable_id,
'order' => $this->order,
];
}