From b890b8300fa7a06bdd253612264bfb36277701dd Mon Sep 17 00:00:00 2001 From: Julien Rosset Date: Mon, 26 May 2025 19:01:51 +0200 Subject: [PATCH] Move machine's extra information from Task to Recipe --- migrations/Version20250526170059.php | 41 ++++++++++++++++++++++ src/Entity/Recipe.php | 51 ++++++++++++++++++++++++++++ src/Entity/Task.php | 13 ------- 3 files changed, 92 insertions(+), 13 deletions(-) create mode 100644 migrations/Version20250526170059.php diff --git a/migrations/Version20250526170059.php b/migrations/Version20250526170059.php new file mode 100644 index 0000000..e411c17 --- /dev/null +++ b/migrations/Version20250526170059.php @@ -0,0 +1,41 @@ +addSql(<<<'SQL' + ALTER TABLE recipe ADD machine_extra_info1 VARCHAR(255) DEFAULT NULL, ADD machine_extra_info2 VARCHAR(255) DEFAULT NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE task DROP machine_extra_info1, DROP machine_extra_info2 + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + ALTER TABLE recipe DROP machine_extra_info1, DROP machine_extra_info2 + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE task ADD machine_extra_info1 VARCHAR(255) DEFAULT NULL, ADD machine_extra_info2 VARCHAR(255) DEFAULT NULL + SQL); + } +} diff --git a/src/Entity/Recipe.php b/src/Entity/Recipe.php index f91715c..ef7ed3f 100644 --- a/src/Entity/Recipe.php +++ b/src/Entity/Recipe.php @@ -24,6 +24,18 @@ class Recipe { #[Assert\NotNull(message: 'Veuillez sélectionner une machine de fabrication')] #[Assert\Valid] private ?Machine $machine = null; + /** + * @var string|null The machine's first extra information + */ + #[ORM\Column(length: 255, nullable: true)] + #[Assert\NotBlank(message: 'Veuillez saisir l\'information complémentaire n° 1', allowNull: true)] + private ?string $machineExtraInfo1 = null; + /** + * @var string|null The machine's second extra information + */ + #[ORM\Column(length: 255, nullable: true)] + #[Assert\NotBlank(message: 'Veuillez saisir l\'information complémentaire n° 2', allowNull: true)] + private ?string $machineExtraInfo2 = null; /** * @var float|null The crafting time, in seconds */ @@ -77,6 +89,45 @@ class Recipe { return $this; } + /** + * The machine's first extra information + * + * @return string|null The machine's first extra information + */ + public function getMachineExtraInfo1 (): ?string { + return $this->machineExtraInfo1; + } + /** + * Set the machine's first extra information + * + * @param string|null $machineExtraInfo1 The machine's first extra information + * + * @return $this + */ + public function setMachineExtraInfo1 (?string $machineExtraInfo1): self { + $this->machineExtraInfo1 = $machineExtraInfo1; + return $this; + } + /** + * The machine's second extra information + * + * @return string|null The machine's second extra information + */ + public function getMachineExtraInfo2 (): ?string { + return $this->machineExtraInfo2; + } + /** + * Set the machine's second extra information + * + * @param string|null $machineExtraInfo2 The machine's second extra information + * + * @return $this + */ + public function setMachineExtraInfo2 (?string $machineExtraInfo2): self { + $this->machineExtraInfo2 = $machineExtraInfo2; + return $this; + } + /** * The crafting time, in seconds * diff --git a/src/Entity/Task.php b/src/Entity/Task.php index cb7d864..ff01a1c 100644 --- a/src/Entity/Task.php +++ b/src/Entity/Task.php @@ -39,19 +39,6 @@ class Task { #[Assert\Valid] private ?Recipe $recipe = null; - /** - * @var string|null The label for the first extra information - */ - #[ORM\Column(length: 255, nullable: true)] - #[Assert\NotBlank(message: 'Veuillez saisir l\'information complémentaire n° 1', allowNull: true)] - private ?string $machineExtraInfo1 = null; - /** - * @var string|null The label for the second extra information - */ - #[ORM\Column(length: 255, nullable: true)] - #[Assert\NotBlank(message: 'Veuillez saisir l\'information complémentaire n° 2', allowNull: true)] - private ?string $machineExtraInfo2 = null; - /** * @var int|null The quantity asked / to produce */