diff --git a/back/.idea/dev.iml b/back/.idea/dev.iml index 4417b18..c0af476 100644 --- a/back/.idea/dev.iml +++ b/back/.idea/dev.iml @@ -81,6 +81,8 @@ + + diff --git a/back/.idea/php.xml b/back/.idea/php.xml index f5bba69..1518336 100644 --- a/back/.idea/php.xml +++ b/back/.idea/php.xml @@ -88,6 +88,8 @@ + + diff --git a/back/migrations/Version20230221150031.php b/back/migrations/Version20230221150031.php new file mode 100644 index 0000000..2abe3d8 --- /dev/null +++ b/back/migrations/Version20230221150031.php @@ -0,0 +1,34 @@ +addSql('CREATE SEQUENCE product_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE product (id INT NOT NULL, name VARCHAR(255) NOT NULL, icon_filename TEXT DEFAULT NULL, banner_filename TEXT DEFAULT NULL, description TEXT DEFAULT 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 SEQUENCE product_id_seq CASCADE'); + $this->addSql('DROP TABLE product'); + } +} diff --git a/back/src/Entity/Product.php b/back/src/Entity/Product.php new file mode 100644 index 0000000..ffbdff3 --- /dev/null +++ b/back/src/Entity/Product.php @@ -0,0 +1,81 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + public function getIconFilename(): ?string + { + return $this->iconFilename; + } + + public function setIconFilename(?string $iconFilename): self + { + $this->iconFilename = $iconFilename; + + return $this; + } + + public function getBannerFilename(): ?string + { + return $this->bannerFilename; + } + + public function setBannerFilename(?string $bannerFilename): self + { + $this->bannerFilename = $bannerFilename; + + return $this; + } + + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): self + { + $this->description = $description; + + return $this; + } +} diff --git a/back/src/Repository/ProductRepository.php b/back/src/Repository/ProductRepository.php new file mode 100644 index 0000000..9e8c42d --- /dev/null +++ b/back/src/Repository/ProductRepository.php @@ -0,0 +1,66 @@ + + * + * @method Product|null find($id, $lockMode = null, $lockVersion = null) + * @method Product|null findOneBy(array $criteria, array $orderBy = null) + * @method Product[] findAll() + * @method Product[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class ProductRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Product::class); + } + + public function save(Product $entity, bool $flush = false): void + { + $this->getEntityManager()->persist($entity); + + if ($flush) { + $this->getEntityManager()->flush(); + } + } + + public function remove(Product $entity, bool $flush = false): void + { + $this->getEntityManager()->remove($entity); + + if ($flush) { + $this->getEntityManager()->flush(); + } + } + +// /** +// * @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() +// ; +// } +}