From c917c42789b4fa659fc9f57967c6ab55c3763dfc Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 10 Jun 2025 12:31:54 +0200 Subject: [PATCH] Add flags property to User entity + migraiton --- src/Bundle/ChillMainBundle/Entity/User.php | 12 ++++++++ .../migrations/Version20250610102953.php | 29 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20250610102953.php diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 8a31779f9..a45cb0209 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -116,6 +116,9 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter #[PhonenumberConstraint] private ?PhoneNumber $phonenumber = null; + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]', 'jsonb' => true])] + private $notificationFlags = []; + /** * User constructor. */ @@ -613,4 +616,13 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter return $this; } + public function getNotificationFlagData(string $flag): array + { + return $this->notificationFlags[$flag] ?? []; + } + + public function setNotificationFlagData(string $flag, array $data): void + { + $this->notificationFlags[$flag] = $data; + } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20250610102953.php b/src/Bundle/ChillMainBundle/migrations/Version20250610102953.php new file mode 100644 index 000000000..1aea75863 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20250610102953.php @@ -0,0 +1,29 @@ +addSql(<<<'SQL' + ALTER TABLE users ADD notificationFlags JSONB DEFAULT '[]' NOT NULL + SQL); + } + + public function down(Schema $schema): void + { + $this->addSql(<<<'SQL' + ALTER TABLE users DROP notificationFlags + SQL); + } +}