feat : ordre d'affichage configurable sur les bâtiments
- Colonne display_order ajoutée à Building avec migration - Seed des valeurs par code : B3 -> 1, B2 -> 2, B1 -> 3, ZT -> 4 - ApiResource trie par displayOrder ASC puis id (NULLs en fin de liste) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
35
migrations/Version20260427154952.php
Normal file
35
migrations/Version20260427154952.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?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 Version20260427154952 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Ajout de la colonne display_order sur building et seed des valeurs par code.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
|
|||||||
#[ORM\Entity]
|
#[ORM\Entity]
|
||||||
#[ORM\Table(name: 'building')]
|
#[ORM\Table(name: 'building')]
|
||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
|
order: ['displayOrder' => 'ASC', 'id' => 'ASC'],
|
||||||
operations: [
|
operations: [
|
||||||
new Get(
|
new Get(
|
||||||
requirements: ['id' => '\d+'],
|
requirements: ['id' => '\d+'],
|
||||||
@@ -43,6 +44,10 @@ class Building
|
|||||||
#[Groups(['building:read', 'building:summary', 'reception:read'])]
|
#[Groups(['building:read', 'building:summary', 'reception:read'])]
|
||||||
private string $code = '';
|
private string $code = '';
|
||||||
|
|
||||||
|
#[ORM\Column(name: 'display_order', type: 'integer', nullable: true)]
|
||||||
|
#[Groups(['building:read', 'building:summary'])]
|
||||||
|
private ?int $displayOrder = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection<int, Reception>
|
* @var Collection<int, Reception>
|
||||||
*/
|
*/
|
||||||
@@ -101,6 +106,18 @@ class Building
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDisplayOrder(): ?int
|
||||||
|
{
|
||||||
|
return $this->displayOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDisplayOrder(?int $displayOrder): self
|
||||||
|
{
|
||||||
|
$this->displayOrder = $displayOrder;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection<int, Reception>
|
* @return Collection<int, Reception>
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user