feat: implement FeaturedGroup and FeaturedProduct controllers, requests, resources, and routes for managing featured products
This commit is contained in:
20
app/Domains/Product/Resources/FeaturedGroupResource.php
Normal file
20
app/Domains/Product/Resources/FeaturedGroupResource.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Product\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FeaturedGroupResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'tenant_codigo' => $this->tenant_codigo,
|
||||
'group_name' => $this->group_name,
|
||||
'product_layout' => $this->product_layout,
|
||||
'featured_products' => FeaturedProductResource::collection($this->whenLoaded('featuredProducts')),
|
||||
];
|
||||
}
|
||||
}
|
||||
20
app/Domains/Product/Resources/FeaturedProductResource.php
Normal file
20
app/Domains/Product/Resources/FeaturedProductResource.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Product\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FeaturedProductResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'featured_group_id' => $this->featured_group_id,
|
||||
'product_id' => $this->product_id,
|
||||
'order' => $this->order,
|
||||
// You can add a nested ProductResource here if needed and when loaded
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user