diff --git a/migrations/Version20260427154952.php b/migrations/Version20260427154952.php new file mode 100644 index 0000000..f63134d --- /dev/null +++ b/migrations/Version20260427154952.php @@ -0,0 +1,35 @@ +addSql('ALTER TABLE building ADD display_order INT DEFAULT NULL'); + + $this->addSql("UPDATE building SET display_order = 1 WHERE code = 'B3'"); + $this->addSql("UPDATE building SET display_order = 2 WHERE code = 'B2'"); + $this->addSql("UPDATE building SET display_order = 3 WHERE code = 'B1'"); + $this->addSql("UPDATE building SET display_order = 4 WHERE code = 'ZT'"); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE building DROP display_order'); + } +} diff --git a/src/Entity/Building.php b/src/Entity/Building.php index 98863cd..e5ace97 100644 --- a/src/Entity/Building.php +++ b/src/Entity/Building.php @@ -16,6 +16,7 @@ use Symfony\Component\Serializer\Attribute\SerializedName; #[ORM\Entity] #[ORM\Table(name: 'building')] #[ApiResource( + order: ['displayOrder' => 'ASC', 'id' => 'ASC'], operations: [ new Get( requirements: ['id' => '\d+'], @@ -43,6 +44,10 @@ class Building #[Groups(['building:read', 'building:summary', 'reception:read'])] private string $code = ''; + #[ORM\Column(name: 'display_order', type: 'integer', nullable: true)] + #[Groups(['building:read', 'building:summary'])] + private ?int $displayOrder = null; + /** * @var Collection */ @@ -101,6 +106,18 @@ class Building return $this; } + public function getDisplayOrder(): ?int + { + return $this->displayOrder; + } + + public function setDisplayOrder(?int $displayOrder): self + { + $this->displayOrder = $displayOrder; + + return $this; + } + /** * @return Collection */