*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'quote_id' => $this->quote_id, 'product_id' => $this->product_id, 'product_name' => $this->product ? $this->product->nom : null, // Assuming 'nom' is the name field 'packaging_id' => $this->packaging_id, 'packages_qty' => $this->packages_qty, 'units_qty' => $this->units_qty, 'description' => $this->description, 'qty_base' => $this->qty_base, 'unit_price' => $this->unit_price, 'unit_price_per_package' => $this->unit_price_per_package, 'tva_rate_id' => $this->tva_rate_id, 'discount_pct' => $this->discount_pct, 'total_ht' => $this->total_ht, 'product' => $this->whenLoaded('product'), 'packaging' => $this->whenLoaded('packaging'), 'tva_rate' => $this->whenLoaded('tvaRate'), ]; } }