diff --git a/public/css/Index/index.css b/public/css/Index/index.css index 7b2c784..11de2c1 100644 --- a/public/css/Index/index.css +++ b/public/css/Index/index.css @@ -43,7 +43,7 @@ ul { } li { - padding-bottom: 20px; + padding-bottom: 4%; } .btn-custom { diff --git a/src/Controller/PlatsController.php b/src/Controller/PlatsController.php index 498590a..373a0ce 100644 --- a/src/Controller/PlatsController.php +++ b/src/Controller/PlatsController.php @@ -72,4 +72,14 @@ final class PlatsController extends AbstractController return $this->redirectToRoute('app_plats_index', [], Response::HTTP_SEE_OTHER); } + + #[Route('/bestplats', name: 'app_plats_best', methods: ['GET'])] + public function getBest(PlatsRepository $platsRepository): Response + { + $bestplats = $platsRepository->findBestPlats(); +// dd($bestplats); + return $this->render('plats/best.html.twig', [ + 'plat' => $bestplats, + ]); + } } diff --git a/src/Repository/PlatsRepository.php b/src/Repository/PlatsRepository.php index a4d8cad..bb0aa7d 100644 --- a/src/Repository/PlatsRepository.php +++ b/src/Repository/PlatsRepository.php @@ -40,4 +40,14 @@ class PlatsRepository extends ServiceEntityRepository // ->getOneOrNullResult() // ; // } + + public function findBestPlats(): ?Plats + { + return $this->createQueryBuilder('p') + ->orderBy('p.Nb_de_commande', 'DESC') + ->setMaxResults(1) + ->getQuery() + ->getOneOrNullResult(); + } + } diff --git a/templates/base.html.twig b/templates/base.html.twig index baf9c01..f85d77c 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -88,7 +88,7 @@
Id | +Nom | +Description | +Prix | +Categorie | +Statut | +Nb_de_commande | +|
---|---|---|---|---|---|---|---|
{{ plat.id }} | +{{ plat.Nom }} | +{{ plat.Description }} | +{{ plat.Prix }} | +{{ plat.Categorie }} | +{{ plat.Statut ? 'Yes' : 'No' }} | +{{ plat.NbDeCommande }} | +|
Aucun enregistrement trouvé | +