diff --git a/migrations/Version20230214111510.php b/migrations/Version20230214111510.php new file mode 100644 index 0000000000000000000000000000000000000000..ee928e9f05d03388be405b98f045895336efab3e --- /dev/null +++ b/migrations/Version20230214111510.php @@ -0,0 +1,31 @@ +<?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 Version20230214111510 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('ALTER TABLE navigation ADD nav_order INT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE navigation DROP nav_order'); + } +} diff --git a/src/Entity/Navigation.php b/src/Entity/Navigation.php index fcdd7a187ba7dc3bfd60510cf00699f13742c680..a9a4f33e4f92ddcffed4bd3db8ec92385b05a8e4 100644 --- a/src/Entity/Navigation.php +++ b/src/Entity/Navigation.php @@ -37,6 +37,9 @@ class Navigation #[ORM\Column] private bool $visible = true; + #[ORM\Column(nullable: true)] + private ?int $navOrder = null; + public function __construct() { $this->child = new ArrayCollection(); @@ -156,4 +159,16 @@ class Navigation return $this; } + + public function getNavOrder(): ?int + { + return $this->navOrder; + } + + public function setNavOrder(?int $navOrder): self + { + $this->navOrder = $navOrder; + + return $this; + } } diff --git a/src/Repository/NavigationRepository.php b/src/Repository/NavigationRepository.php index b19512e9ac56c0c7b0b6c9ed087b6bfe00da9e7e..11a82d855bf1525f398e905de84a8b76e721820e 100644 --- a/src/Repository/NavigationRepository.php +++ b/src/Repository/NavigationRepository.php @@ -49,6 +49,7 @@ class NavigationRepository extends ServiceEntityRepository ->andWhere('n.position = :position') ->andWhere('n.visible = 1') ->setParameter('position', $position) + ->orderBy('n.navOrder') ->getQuery() ->getResult(); }