<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\GenderRepository")
*/
class Gender
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=20)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="gender")
*/
private $users;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Child", mappedBy="gender")
*/
private $children;
/**
* @ORM\Column(type="string", length=50)
*/
private $nameEn;
public function __construct()
{
$this->users = new ArrayCollection();
$this->children = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setGender($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
// set the owning side to null (unless already changed)
if ($user->getGender() === $this) {
$user->setGender(null);
}
}
return $this;
}
public function __toString()
{
return $this->getName();
}
/**
* @return Collection|Child[]
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChild(Child $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->setGender($this);
}
return $this;
}
public function removeChild(Child $child): self
{
if ($this->children->contains($child)) {
$this->children->removeElement($child);
// set the owning side to null (unless already changed)
if ($child->getGender() === $this) {
$child->setGender(null);
}
}
return $this;
}
public function getNameEn(): ?string
{
return $this->nameEn;
}
public function setNameEn(?string $nameEn): self
{
$this->nameEn = $nameEn;
return $this;
}
}