src/Entity/Gender.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\GenderRepository")
  8.  */
  9. class Gender
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=20)
  19.      */
  20.     private $name;
  21.     /**
  22.      * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="gender")
  23.      */
  24.     private $users;
  25.     /**
  26.      * @ORM\OneToMany(targetEntity="App\Entity\Child", mappedBy="gender")
  27.      */
  28.     private $children;
  29.     /**
  30.      * @ORM\Column(type="string", length=50)
  31.      */
  32.     private $nameEn;
  33.     public function __construct()
  34.     {
  35.         $this->users = new ArrayCollection();
  36.         $this->children = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getName(): ?string
  43.     {
  44.         return $this->name;
  45.     }
  46.     public function setName(string $name): self
  47.     {
  48.         $this->name $name;
  49.         return $this;
  50.     }
  51.     /**
  52.      * @return Collection|User[]
  53.      */
  54.     public function getUsers(): Collection
  55.     {
  56.         return $this->users;
  57.     }
  58.     public function addUser(User $user): self
  59.     {
  60.         if (!$this->users->contains($user)) {
  61.             $this->users[] = $user;
  62.             $user->setGender($this);
  63.         }
  64.         return $this;
  65.     }
  66.     public function removeUser(User $user): self
  67.     {
  68.         if ($this->users->contains($user)) {
  69.             $this->users->removeElement($user);
  70.             // set the owning side to null (unless already changed)
  71.             if ($user->getGender() === $this) {
  72.                 $user->setGender(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     public function __toString()
  78.     {
  79.         return $this->getName();
  80.     }
  81.     /**
  82.      * @return Collection|Child[]
  83.      */
  84.     public function getChildren(): Collection
  85.     {
  86.         return $this->children;
  87.     }
  88.     public function addChild(Child $child): self
  89.     {
  90.         if (!$this->children->contains($child)) {
  91.             $this->children[] = $child;
  92.             $child->setGender($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeChild(Child $child): self
  97.     {
  98.         if ($this->children->contains($child)) {
  99.             $this->children->removeElement($child);
  100.             // set the owning side to null (unless already changed)
  101.             if ($child->getGender() === $this) {
  102.                 $child->setGender(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     public function getNameEn(): ?string
  108.     {
  109.         return $this->nameEn;
  110.     }
  111.     public function setNameEn(?string $nameEn): self
  112.     {
  113.         $this->nameEn $nameEn;
  114.         return $this;
  115.     }
  116. }