<?php
namespace App\Entity;
use App\Entity\Eg\Osm\ParkingCarDrawingDetails;
use App\Repository\ControllerUserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ControllerUserRepository::class)]
#[UniqueEntity('controllerId')]
class ControllerUser
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;
#[Assert\GreaterThan(0)]
#[Assert\NotNull]
#[ORM\Column(type: 'integer', unique: true)]
private $controllerId;
#[ORM\OneToMany(targetEntity: UserPair::class, mappedBy: 'firstUser', orphanRemoval: true)]
private $userPairs;
#[ORM\OneToMany(targetEntity: UserSession::class, mappedBy: 'user')]
private $userSessions;
#[Assert\GreaterThan(0)]
#[ORM\Column(type: 'integer', nullable: true)]
private $controllerEgId;
#[ORM\Column(type: 'string', length: 70, options: ['default' => '$2b$10$rfdfCXR4hDlQcIJz0ar3aOjGDy5XE3j3hvlgcpsThaeQl6iqxyswu'])]
private $password = '$2b$10$rfdfCXR4hDlQcIJz0ar3aOjGDy5XE3j3hvlgcpsThaeQl6iqxyswu';
#[ORM\OneToMany(targetEntity: ParkingCarDrawingDetails::class, mappedBy: 'createdBy')]
private $parkingCarDrawingDetails;
#[ORM\Column(type: 'boolean', options: ['default' => true])]
private $active = true;
public function __construct()
{
$this->userPairs = new ArrayCollection();
$this->userSessions = new ArrayCollection();
$this->parkingCarDrawingDetails = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getControllerId(): ?int
{
return $this->controllerId;
}
public function setControllerId(int $controllerId): self
{
$this->controllerId = $controllerId;
return $this;
}
/**
* @return Collection<int, UserPair>
*/
public function getUserPairs(): Collection
{
return $this->userPairs;
}
public function addUserPair(UserPair $userPair): self
{
if (!$this->userPairs->contains($userPair)) {
$this->userPairs[] = $userPair;
$userPair->setFirstUser($this);
}
return $this;
}
public function removeUserPair(UserPair $userPair): self
{
if ($this->userPairs->removeElement($userPair)) {
// set the owning side to null (unless already changed)
if ($userPair->getFirstUser() === $this) {
$userPair->setFirstUser(null);
}
}
return $this;
}
/**
* @return Collection<int, UserSession>
*/
public function getUserSessions(): Collection
{
return $this->userSessions;
}
public function addUserSession(UserSession $userSession): self
{
if (!$this->userSessions->contains($userSession)) {
$this->userSessions[] = $userSession;
$userSession->setUser($this);
}
return $this;
}
public function removeUserSession(UserSession $userSession): self
{
if ($this->userSessions->removeElement($userSession)) {
// set the owning side to null (unless already changed)
if ($userSession->getUser() === $this) {
$userSession->setUser(null);
}
}
return $this;
}
public function getControllerEgId(): ?int
{
return $this->controllerEgId;
}
public function setControllerEgId(?int $controllerEgId): self
{
$this->controllerEgId = $controllerEgId;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @return Collection<int, ParkingCarDrawingDetails>
*/
public function getParkingCarDrawingDetails(): Collection
{
return $this->parkingCarDrawingDetails;
}
public function addParkingCarDrawingDetails(ParkingCarDrawingDetails $parkingCarDrawingDetails): self
{
if (!$this->parkingCarDrawingDetails->contains($parkingCarDrawingDetails)) {
$this->parkingCarDrawingDetails[] = $parkingCarDrawingDetails;
$parkingCarDrawingDetails->setCreatedBy($this);
}
return $this;
}
public function removeParkingCarDrawingDetails(ParkingCarDrawingDetails $parkingCarDrawingDetails): self
{
if ($this->parkingCarDrawingDetails->removeElement($parkingCarDrawingDetails)) {
// set the owning side to null (unless already changed)
if ($parkingCarDrawingDetails->getCreatedBy() === $this) {
$parkingCarDrawingDetails->setCreatedBy(null);
}
}
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
}