feat: add brand and category relationships to products, update requests and resources, and seed product catalog from images

This commit is contained in:
2026-06-29 13:47:05 -03:00
parent 49771ebb13
commit 24235c5ca9
28 changed files with 454 additions and 14 deletions

View File

@@ -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()
),