27 lines
753 B
PHP
27 lines
753 B
PHP
<?php
|
|
|
|
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;
|
|
|
|
class FeaturedVariantResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'featured_group_id' => $this->featured_group_id,
|
|
'groupable_type' => match ($this->groupable_type) {
|
|
ProductVariant::class => 'variant',
|
|
Bundle::class => 'bundle',
|
|
default => 'unknown',
|
|
},
|
|
'groupable_id' => $this->groupable_id,
|
|
'order' => $this->order,
|
|
];
|
|
}
|
|
}
|