src/Entity/UserStatus.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\UserStatusRepository")
  8.  */
  9. class UserStatus
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=255)
  19.      */
  20.     private $name;
  21.     /**
  22.      * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="status")
  23.      */
  24.     private $users;
  25.     public function __construct()
  26.     {
  27.         $this->users = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getName(): ?string
  34.     {
  35.         return $this->name;
  36.     }
  37.     public function setName(string $name): self
  38.     {
  39.         $this->name $name;
  40.         return $this;
  41.     }
  42.     /**
  43.      * @return Collection|User[]
  44.      */
  45.     public function getUsers(): Collection
  46.     {
  47.         return $this->users;
  48.     }
  49.     public function addUser(User $user): self
  50.     {
  51.         if (!$this->users->contains($user)) {
  52.             $this->users[] = $user;
  53.             $user->setStatus($this);
  54.         }
  55.         return $this;
  56.     }
  57.     public function removeUser(User $user): self
  58.     {
  59.         if ($this->users->contains($user)) {
  60.             $this->users->removeElement($user);
  61.             // set the owning side to null (unless already changed)
  62.             if ($user->getStatus() === $this) {
  63.                 $user->setStatus(null);
  64.             }
  65.         }
  66.         return $this;
  67.     }
  68.     public function __toString(): string
  69.     {
  70.         return $this->name;
  71.     }
  72. }