src/Entity/Gos/UserPosition.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\Gos\UserPositionRepository")
  9.  * @ORM\HasLifecycleCallbacks
  10.  * @UniqueEntity("name")
  11.  */
  12. class UserPosition
  13. {
  14.     /**
  15.      * @ORM\Id()
  16.      * @ORM\GeneratedValue()
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\PortalSettings", inversedBy="positions")
  26.      */
  27.     private $portalSettings;
  28.     /**
  29.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\User", mappedBy="position")
  30.      */
  31.     private $user;
  32.     /**
  33.      * @ORM\Column(type="datetime")
  34.      */
  35.     private $createdAt;
  36.     /**
  37.      * @ORM\Column(type="datetime", nullable=true)
  38.      */
  39.     private $updatedAt;
  40.     public function __toString()
  41.     {
  42.         return $this->name;
  43.     }
  44.     public function __construct()
  45.     {
  46.         $this->portalSettings = new ArrayCollection();
  47.         $this->user = new ArrayCollection();
  48.     }
  49.     /** @ORM\PrePersist() */
  50.     public function prePersist()
  51.     {
  52.         $this->createdAt = new \DateTime();
  53.     }
  54.     /** @ORM\PreUpdate() */
  55.     public function preUpdate()
  56.     {
  57.         $this->updatedAt = new \DateTime();
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getName(): ?string
  64.     {
  65.         return $this->name;
  66.     }
  67.     public function setName(string $name): self
  68.     {
  69.         $this->name $name;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection|PortalSettings[]
  74.      */
  75.     public function getPortalSettings(): Collection
  76.     {
  77.         return $this->portalSettings;
  78.     }
  79.     public function addPortalSetting(PortalSettings $portalSetting): self
  80.     {
  81.         if (!$this->portalSettings->contains($portalSetting)) {
  82.             $this->portalSettings[] = $portalSetting;
  83.         }
  84.         return $this;
  85.     }
  86.     public function removePortalSetting(PortalSettings $portalSetting): self
  87.     {
  88.         if ($this->portalSettings->contains($portalSetting)) {
  89.             $this->portalSettings->removeElement($portalSetting);
  90.         }
  91.         return $this;
  92.     }
  93.     /**
  94.      * @return Collection|User[]
  95.      */
  96.     public function getUser(): Collection
  97.     {
  98.         return $this->user;
  99.     }
  100.     public function addUser(User $user): self
  101.     {
  102.         if (!$this->user->contains($user)) {
  103.             $this->user[] = $user;
  104.             $user->setPosition($this);
  105.         }
  106.         return $this;
  107.     }
  108.     public function removeUser(User $user): self
  109.     {
  110.         if ($this->user->contains($user)) {
  111.             $this->user->removeElement($user);
  112.             // set the owning side to null (unless already changed)
  113.             if ($user->getPosition() === $this) {
  114.                 $user->setPosition(null);
  115.             }
  116.         }
  117.         return $this;
  118.     }
  119.     public function getCreatedAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->createdAt;
  122.     }
  123.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  124.     {
  125.         $this->createdAt $createdAt;
  126.         return $this;
  127.     }
  128.     public function getUpdatedAt(): ?\DateTimeInterface
  129.     {
  130.         return $this->updatedAt;
  131.     }
  132.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  133.     {
  134.         $this->updatedAt $updatedAt;
  135.         return $this;
  136.     }
  137. }