From a9493bfb0ff33ec080eb5a82866672e7652f44d0 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 10 Feb 2026 16:01:43 +0100 Subject: [PATCH] update UO entity to handle roles --- migrations/Version20260210131727.php | 36 ++++++++++++++++++++++++++++ src/Entity/UsersOrganizations.php | 15 ++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 migrations/Version20260210131727.php diff --git a/migrations/Version20260210131727.php b/migrations/Version20260210131727.php new file mode 100644 index 0000000..b313cf2 --- /dev/null +++ b/migrations/Version20260210131727.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE users_organizations ADD role_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE users_organizations ADD CONSTRAINT FK_4B991472D60322AC FOREIGN KEY (role_id) REFERENCES roles (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_4B991472D60322AC ON users_organizations (role_id)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE users_organizations DROP CONSTRAINT FK_4B991472D60322AC'); + $this->addSql('DROP INDEX IDX_4B991472D60322AC'); + $this->addSql('ALTER TABLE users_organizations DROP role_id'); + } +} diff --git a/src/Entity/UsersOrganizations.php b/src/Entity/UsersOrganizations.php index d524d46..efe84e0 100644 --- a/src/Entity/UsersOrganizations.php +++ b/src/Entity/UsersOrganizations.php @@ -41,6 +41,9 @@ class UsersOrganizations #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $modifiedAt = null; + #[ORM\ManyToOne] + private ?Roles $role = null; + public function __construct() { $this->isActive = true; // Default value for isActive @@ -147,4 +150,16 @@ class UsersOrganizations return $this; } + + public function getRole(): ?Roles + { + return $this->role; + } + + public function setRole(?Roles $role): static + { + $this->role = $role; + + return $this; + } }