From 4e1cf2e348d9e7cf71e31a448f5d2015b0eaa356 Mon Sep 17 00:00:00 2001 From: Kayn Ty Date: Fri, 20 Apr 2018 09:44:15 +0200 Subject: [PATCH] fields in listing --- app/Resources/views/product/index.html.twig | 2 ++ app/Resources/views/productcategory/index.html.twig | 3 +++ src/AppBundle/Controller/ProductCategoryController.php | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Resources/views/product/index.html.twig b/app/Resources/views/product/index.html.twig index 55566316..ea728dea 100755 --- a/app/Resources/views/product/index.html.twig +++ b/app/Resources/views/product/index.html.twig @@ -7,6 +7,7 @@ Id + Category Name Image Price @@ -22,6 +23,7 @@ {{ product.id }} + {{ product.category.name }} {{ product.name }} {{ product.image }} {{ product.price }} diff --git a/app/Resources/views/productcategory/index.html.twig b/app/Resources/views/productcategory/index.html.twig index ba9a9dd8..aa604c17 100755 --- a/app/Resources/views/productcategory/index.html.twig +++ b/app/Resources/views/productcategory/index.html.twig @@ -8,6 +8,7 @@ Id Nom + Produits Actions @@ -19,6 +20,7 @@ href="{{ path('productcategory_show', { 'id': productCategory.id }) }}">{{ productCategory.id }} {{ productCategory.name }} + {{ productCategory.products|length }} diff --git a/src/AppBundle/Controller/ProductCategoryController.php b/src/AppBundle/Controller/ProductCategoryController.php index 24582924..fe31afcc 100755 --- a/src/AppBundle/Controller/ProductCategoryController.php +++ b/src/AppBundle/Controller/ProductCategoryController.php @@ -23,7 +23,8 @@ class ProductCategoryController extends Controller { public function indexAction() { $em = $this->getDoctrine()->getManager(); - $productCategories = $em->getRepository( 'AppBundle:ProductCategory' )->findByUser($this->getUser() ); + $currentUser = $this->getUser(); + $productCategories = $currentUser->getCategories(); return $this->render( 'productcategory/index.html.twig', [