feat(desfile): implement entry management with image handling and variant synchronization

This commit is contained in:
2026-08-14 11:24:17 -03:00
parent 7fbdc00c64
commit 21b0517e6c
10 changed files with 767 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Domains\Desfile\Resources;
use App\Domains\Catalog\Models\CatalogItem;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/** @mixin CatalogItem */
class EntryResource extends JsonResource
{
/** @return array<string, mixed> */
public function toArray(Request $request): array
{
$image = $this->allAttachments->first();
return [
'id' => $this->id,
'variants' => $this->variants->map(function ($variant): array {
$values = $variant->selectionValues();
return [
'id' => $variant->id,
'type' => $values->get('tipo'),
'sector' => $values->get('sector'),
'row' => $values->get('fila'),
'seat' => $values->get('asiento'),
'price' => number_format($variant->getPrice(), 2, '.', ''),
];
})->values(),
'image' => $image === null ? null : [
'key' => $image->key,
'filename' => $image->filename,
'url' => $image->getTemporaryUrl(1440),
'is_enabled' => (bool) $image->pivot->is_enabled,
],
];
}
}