feat: multiple hotelcodes assignable to users
This commit is contained in:
+21
-4
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user