feat: add brand and category relationships to products, update requests and resources, and seed product catalog from images
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Domains\Catalog\Resources;
|
||||
|
||||
use App\Domains\Catalog\Resources\BrandResource;
|
||||
use App\Domains\Catalog\Resources\CategoryResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -19,10 +21,13 @@ class ProductResource extends JsonResource
|
||||
'id' => $this->id,
|
||||
'tenant_codigo' => $this->tenant_codigo,
|
||||
'categoria_id' => $this->categoria_id,
|
||||
'brand_id' => $this->brand_id,
|
||||
'slug' => $this->slug,
|
||||
'nombre' => $this->nombre,
|
||||
'descripcion' => $this->descripcion,
|
||||
'precio' => $this->precio,
|
||||
'category' => CategoryResource::make($this->whenLoaded('category')),
|
||||
'brand' => BrandResource::make($this->whenLoaded('brand')),
|
||||
'images' => $this->whenLoaded('attachments', fn () =>
|
||||
$this->attachments->map(fn ($attachment) => $attachment->getTemporaryUrl(1440))->values()
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user