From 21c7a0c317fbff8bf6b8a6bb474f211adac15f77 Mon Sep 17 00:00:00 2001 From: Julien Rosset Date: Fri, 30 May 2025 19:00:16 +0200 Subject: [PATCH] Material type: add unit --- migrations/Version20250530165755.php | 35 ++++++++++++++++++++++++++++ src/Entity/MaterialType.php | 27 +++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 migrations/Version20250530165755.php diff --git a/migrations/Version20250530165755.php b/migrations/Version20250530165755.php new file mode 100644 index 0000000..03c1886 --- /dev/null +++ b/migrations/Version20250530165755.php @@ -0,0 +1,35 @@ +addSql(<<<'SQL' + ALTER TABLE material_type ADD unit VARCHAR(5) DEFAULT NULL + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + ALTER TABLE material_type DROP unit + SQL); + } +} diff --git a/src/Entity/MaterialType.php b/src/Entity/MaterialType.php index 58d97a4..3c433bb 100644 --- a/src/Entity/MaterialType.php +++ b/src/Entity/MaterialType.php @@ -17,6 +17,13 @@ class MaterialType implements Stringable { use TBaseEntity; use TNamedEntity; + /** + * @var string|null The unit + */ + #[ORM\Column(length: 5, nullable: true)] + #[Assert\NotBlank(message: 'Veuillez saisir une unité', allowNull: true)] + private ?string $unit = null; + /** * @var string|null The “stack” name */ @@ -32,6 +39,26 @@ class MaterialType implements Stringable { #[Assert\Positive(message: 'La taille de pile doit être strictement positive')] private ?int $stackSize = null; + /** + * The unit + * + * @return string|null The unit + */ + public function getUnit (): ?string { + return $this->unit; + } + /** + * Set the unit + * + * @param string|null $unit The unit + * + * @return $this + */ + public function setUnit (?string $unit): self { + $this->unit = $unit; + return $this; + } + /** * The “stack” name *