From 94ff83d89afc69496c03865d319b33fb0b14cbd8 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 1 Jan 2022 23:10:58 +0100 Subject: [PATCH] Add fridge related entities --- src/Controller/Admin/DashboardController.php | 4 + src/Controller/Admin/FridgeCrudController.php | 36 ++++++++ .../Admin/FridgeProductLineCrudController.php | 36 ++++++++ .../Admin/RecipeProductLineCrudController.php | 3 - src/Entity/Fridge.php | 90 +++++++++++++++++++ src/Entity/FridgeProductLine.php | 24 +++++ src/Repository/FridgeRepository.php | 50 +++++++++++ 7 files changed, 240 insertions(+), 3 deletions(-) create mode 100644 src/Controller/Admin/FridgeCrudController.php create mode 100644 src/Controller/Admin/FridgeProductLineCrudController.php create mode 100644 src/Entity/Fridge.php create mode 100644 src/Entity/FridgeProductLine.php create mode 100644 src/Repository/FridgeRepository.php diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index c835e08..657df3e 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -2,6 +2,8 @@ namespace App\Controller\Admin; +use App\Entity\Fridge; +use App\Entity\FridgeProductLine; use App\Entity\Product; use App\Entity\QuantityUnit; use App\Entity\Recipe; @@ -44,6 +46,8 @@ class DashboardController extends AbstractDashboardController yield MenuItem::section('Product lists', 'fas fa-folder-open'); yield MenuItem::linkToCrud('Recipes', 'fas fa-list', Recipe::class); yield MenuItem::linkToCrud('Recipe product lines', 'fas fa-list', RecipeProductLine::class); + yield MenuItem::linkToCrud('Fridges', 'fas fa-list', Fridge::class); + yield MenuItem::linkToCrud('Fridge product lines', 'fas fa-list', FridgeProductLine::class); yield MenuItem::section('Administration', 'fas fa-folder-open'); yield MenuItem::linkToCrud('User', 'fas fa-list', User::class); diff --git a/src/Controller/Admin/FridgeCrudController.php b/src/Controller/Admin/FridgeCrudController.php new file mode 100644 index 0000000..9ac18a2 --- /dev/null +++ b/src/Controller/Admin/FridgeCrudController.php @@ -0,0 +1,36 @@ +productLines = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + + return $this; + } + + /** + * @return Collection|FridgeProductLine[] + */ + public function getProductLines(): Collection + { + return $this->productLines; + } + + public function addProductLine(FridgeProductLine $productLine): self + { + if (!$this->productLines->contains($productLine)) { + $this->productLines[] = $productLine; + $productLine->setFridge($this); + } + + return $this; + } + + public function removeProductLine(FridgeProductLine $productLine): self + { + if ($this->productLines->removeElement($productLine)) { + // set the owning side to null (unless already changed) + if ($productLine->getFridge() === $this) { + $productLine->setFridge(null); + } + } + + return $this; + } +} diff --git a/src/Entity/FridgeProductLine.php b/src/Entity/FridgeProductLine.php new file mode 100644 index 0000000..4bd33a3 --- /dev/null +++ b/src/Entity/FridgeProductLine.php @@ -0,0 +1,24 @@ +fridge; + } + + public function setFridge(?Fridge $fridge): self + { + $this->fridge = $fridge; + + return $this; + } +} \ No newline at end of file diff --git a/src/Repository/FridgeRepository.php b/src/Repository/FridgeRepository.php new file mode 100644 index 0000000..641ccc6 --- /dev/null +++ b/src/Repository/FridgeRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('f') + ->andWhere('f.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('f.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Fridge + { + return $this->createQueryBuilder('f') + ->andWhere('f.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +}