From 7a43efc9b769c85a752538573ee717cbbf64cbf7 Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Fri, 16 Jan 2026 13:44:08 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(produit):=20Ajoute=20l'entit?= =?UTF-8?q?=C3=A9=20Produit,=20son=20repository=20et=20la=20migration=20as?= =?UTF-8?q?soci=C3=A9e.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrations/Version20260116124335.php | 32 +++++++ src/Entity/Product.php | 125 +++++++++++++++++++++++++++ src/Repository/ProductRepository.php | 43 +++++++++ 3 files changed, 200 insertions(+) create mode 100644 migrations/Version20260116124335.php create mode 100644 src/Entity/Product.php create mode 100644 src/Repository/ProductRepository.php diff --git a/migrations/Version20260116124335.php b/migrations/Version20260116124335.php new file mode 100644 index 0000000..2e3def1 --- /dev/null +++ b/migrations/Version20260116124335.php @@ -0,0 +1,32 @@ +addSql('CREATE TABLE product (id SERIAL NOT NULL, ref VARCHAR(255) NOT NULL, category VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, price_day DOUBLE PRECISION NOT NULL, price_sup DOUBLE PRECISION NOT NULL, installation DOUBLE PRECISION NOT NULL, caution DOUBLE PRECISION NOT NULL, PRIMARY KEY(id))'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('DROP TABLE product'); + } +} diff --git a/src/Entity/Product.php b/src/Entity/Product.php new file mode 100644 index 0000000..160d457 --- /dev/null +++ b/src/Entity/Product.php @@ -0,0 +1,125 @@ +id; + } + + public function getRef(): ?string + { + return $this->ref; + } + + public function setRef(string $ref): static + { + $this->ref = $ref; + + return $this; + } + + public function getCategory(): ?string + { + return $this->category; + } + + public function setCategory(string $category): static + { + $this->category = $category; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getPriceDay(): ?float + { + return $this->priceDay; + } + + public function setPriceDay(float $priceDay): static + { + $this->priceDay = $priceDay; + + return $this; + } + + public function getPriceSup(): ?float + { + return $this->priceSup; + } + + public function setPriceSup(float $priceSup): static + { + $this->priceSup = $priceSup; + + return $this; + } + + public function getInstallation(): ?float + { + return $this->installation; + } + + public function setInstallation(float $installation): static + { + $this->installation = $installation; + + return $this; + } + + public function getCaution(): ?float + { + return $this->caution; + } + + public function setCaution(float $caution): static + { + $this->caution = $caution; + + return $this; + } +} diff --git a/src/Repository/ProductRepository.php b/src/Repository/ProductRepository.php new file mode 100644 index 0000000..9564bc1 --- /dev/null +++ b/src/Repository/ProductRepository.php @@ -0,0 +1,43 @@ + + */ +class ProductRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Product::class); + } + + // /** + // * @return Product[] Returns an array of Product objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('p') + // ->andWhere('p.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('p.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Product + // { + // return $this->createQueryBuilder('p') + // ->andWhere('p.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +}