feat: ajout entity OrderNumber pour la gestion des numeros de commande
src/Entity/OrderNumber.php (nouveau): - id: int auto-increment - numOrder: string(50) unique, le numero de commande - createdAt: DateTimeImmutable, date de creation (auto dans le constructeur) - isUsed: bool, false par defaut, marque via markAsUsed() src/Repository/OrderNumberRepository.php (nouveau): - Repository Doctrine standard pour OrderNumber migrations/Version20260402201935.php: - Table order_number avec index unique sur num_order - created_at TIMESTAMP, is_used BOOLEAN Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
32
migrations/Version20260402201935.php
Normal file
32
migrations/Version20260402201935.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260402201935 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
55
src/Entity/OrderNumber.php
Normal file
55
src/Entity/OrderNumber.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\OrderNumberRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: OrderNumberRepository::class)]
|
||||
class OrderNumber
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 50, unique: true)]
|
||||
private string $numOrder;
|
||||
|
||||
#[ORM\Column]
|
||||
private \DateTimeImmutable $createdAt;
|
||||
|
||||
#[ORM\Column]
|
||||
private bool $isUsed = false;
|
||||
|
||||
public function __construct(string $numOrder)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
18
src/Repository/OrderNumberRepository.php
Normal file
18
src/Repository/OrderNumberRepository.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\OrderNumber;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<OrderNumber>
|
||||
*/
|
||||
class OrderNumberRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, OrderNumber::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user