*/ 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, ], ]; } }