feat: multiple hotelcodes assignable to users

This commit is contained in:
Björn Fromme
2025-01-08 10:07:19 +01:00
parent 5a07d95837
commit c15188c43c
16 changed files with 256 additions and 67 deletions
+21 -4
View File
@@ -54,6 +54,9 @@ class User implements UserInterface, TimestampableEntityInterface
#[ORM\Column(length: 32, nullable: true)]
private ?string $hotelCode = null;
#[ORM\Column(type: 'json')]
private array $hotelCodes = [];
#[ORM\Column]
private bool $muteNotifications = false;
@@ -256,14 +259,14 @@ class User implements UserInterface, TimestampableEntityInterface
return $this;
}
public function getHotelCode(): ?string
public function getHotelCodes(): array
{
return $this->hotelCode;
return $this->hotelCodes;
}
public function setHotelCode(?string $hotelCode): static
public function setHotelCodes(array $hotelCodes): static
{
$this->hotelCode = $hotelCode;
$this->hotelCodes = $hotelCodes;
return $this;
}
@@ -279,4 +282,18 @@ class User implements UserInterface, TimestampableEntityInterface
return $this;
}
public function hasHotelCodeMatch(string $hotelCode): bool
{
foreach ($this->hotelCodes as $userHotelCode) {
if (
str_starts_with($hotelCode, $userHotelCode)
|| str_ends_with($hotelCode, $userHotelCode)
) {
return true;
}
}
return false;
}
}