}', name: 'app_product')] public function __invoke(int $productId): Response { $product = Product::with([ 'price' => fn($query) => $query->orderBy('created_at', 'desc') ])->find($productId); if(null === $product) { throw $this->createNotFoundException('Product not found'); } $priceList = $product->price()->pluck('price')->implode(','); $priceDates = $product->price()->pluck('created_at')->map(fn($date) => $date->format('Y-m-d'))->implode("','"); return $this->render('product.html.twig', ['product' => $product, 'price_list' => $priceList, 'price_dates' => $priceDates]); } }