diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index 24ce68e..e7ab1b9 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -3,6 +3,7 @@ namespace App\Controller\Admin; use App\Entity\Product; +use App\Entity\QuantityUnit; use App\Entity\User; use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; @@ -36,6 +37,7 @@ class DashboardController extends AbstractDashboardController yield MenuItem::section('Products', 'fas fa-folder-open'); yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home'); yield MenuItem::linkToCrud('Products', 'fas fa-list', Product::class); + yield MenuItem::linkToCrud('Quantity units', 'fas fa-list', QuantityUnit::class); yield MenuItem::section('Administration', 'fas fa-folder-open'); yield MenuItem::linkToCrud('User', 'fas fa-list', User::class); diff --git a/src/Controller/Admin/ProductCrudController.php b/src/Controller/Admin/ProductCrudController.php index 0521f64..416da12 100644 --- a/src/Controller/Admin/ProductCrudController.php +++ b/src/Controller/Admin/ProductCrudController.php @@ -5,6 +5,7 @@ namespace App\Controller\Admin; use App\Entity\Product; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; +use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; @@ -30,6 +31,7 @@ class ProductCrudController extends AbstractCrudController $fields[] = BooleanField::new('enabled'); $fields[] = TextField::new('name'); $fields[] = TextEditorField::new('description'); + $fields[] = AssociationField::new('quantityUnit'); return $fields; } diff --git a/src/Controller/Admin/QuantityUnitCrudController.php b/src/Controller/Admin/QuantityUnitCrudController.php new file mode 100644 index 0000000..e8dfa1d --- /dev/null +++ b/src/Controller/Admin/QuantityUnitCrudController.php @@ -0,0 +1,37 @@ +id; @@ -50,4 +53,16 @@ class Product return $this; } + + public function getQuantityUnit(): ?QuantityUnit + { + return $this->quantityUnit; + } + + public function setQuantityUnit(QuantityUnit $quantityUnit): self + { + $this->quantityUnit = $quantityUnit; + + return $this; + } } diff --git a/src/Entity/QuantityUnit.php b/src/Entity/QuantityUnit.php new file mode 100644 index 0000000..2c23c72 --- /dev/null +++ b/src/Entity/QuantityUnit.php @@ -0,0 +1,55 @@ +name; + } + + 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; + } +} diff --git a/src/Repository/QuantityUnitRepository.php b/src/Repository/QuantityUnitRepository.php new file mode 100644 index 0000000..b333815 --- /dev/null +++ b/src/Repository/QuantityUnitRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('q') + ->andWhere('q.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('q.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?QuantityUnit + { + return $this->createQueryBuilder('q') + ->andWhere('q.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +}