diff --git a/migrations/Version20260402201935.php b/migrations/Version20260402201935.php new file mode 100644 index 0000000..cb7bd73 --- /dev/null +++ b/migrations/Version20260402201935.php @@ -0,0 +1,32 @@ +addSql('CREATE TABLE order_number (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, num_order VARCHAR(50) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, is_used BOOLEAN NOT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_551F0F81B2AA22EE ON order_number (num_order)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('DROP TABLE order_number'); + } +} diff --git a/src/Entity/OrderNumber.php b/src/Entity/OrderNumber.php new file mode 100644 index 0000000..7de2962 --- /dev/null +++ b/src/Entity/OrderNumber.php @@ -0,0 +1,55 @@ +numOrder = $numOrder; + $this->createdAt = new \DateTimeImmutable(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getNumOrder(): string + { + return $this->numOrder; + } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function isUsed(): bool + { + return $this->isUsed; + } + + public function markAsUsed(): void + { + $this->isUsed = true; + } +} diff --git a/src/Repository/OrderNumberRepository.php b/src/Repository/OrderNumberRepository.php new file mode 100644 index 0000000..33e93b0 --- /dev/null +++ b/src/Repository/OrderNumberRepository.php @@ -0,0 +1,18 @@ + + */ +class OrderNumberRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, OrderNumber::class); + } +}