src/Entity/Country.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CountryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Serializer\Annotation\Ignore;
  9. /**
  10.  * @ORM\Entity(repositoryClass=CountryRepository::class)
  11.  */
  12. class Country
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @Groups({"atpmatch_result:list", "atpmatch_result:item","country:list", "country:item","round:list", "round:item","drawline:list", "drawline:item","event:list","event:item"})
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=180)
  23.      * @Groups({"atpmatch_result:list", "atpmatch_result:item","country:list", "country:item","player:list", "player:item","round:list", "round:item","drawline:list", "drawline:item","event:list","event:item"})
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="string", length=3)
  28.      * @Groups({"atpmatch_result:list", "atpmatch_result:item", "country:list", "country:item","player:list", "player:item","round:list", "round:item","drawline:list", "drawline:item","event:list","event:item"})
  29.      */
  30.     private $code;
  31.     /**
  32.      * @ORM\Column(type="string", length=3)
  33.      * @Groups({"atpmatch_result:list", "atpmatch_result:item","country:list", "country:item","player:list", "player:item","event:list","event:item","round:list", "round:item"})
  34.      */
  35.     private $longCode;
  36.     /**
  37.      * @ORM\Column(type="string", length=180)
  38.      * @Groups({"country:list", "country:item","player:list", "player:item"})
  39.      */
  40.     private $region;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=Player::class, mappedBy="country")
  43.      * @Ignore()
  44.      */
  45.     private $players;
  46.     /**
  47.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="country")
  48.      * @Ignore()
  49.      */
  50.     private $users;
  51.     /**
  52.      * @var string
  53.      */
  54.     private $flag;
  55.     /**
  56.      * @ORM\Column(type="integer", nullable=true)
  57.      */
  58.     private $sortOrder;
  59.     public function __construct()
  60.     {
  61.         $this->players = new ArrayCollection();
  62.     }
  63.     public function __toString()
  64.     {
  65.         return $this->getName();
  66.     }
  67.     /**
  68.      * @return Collection|Player[]
  69.      */
  70.     public function getPlayers(): Collection
  71.     {
  72.         return $this->players;
  73.     }
  74.     public function addPlayer(Player $player): self
  75.     {
  76.         if (!$this->players->contains($player)) {
  77.             $this->players[] = $player;
  78.             $player->setCountry($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removePlayer(Player $player): self
  83.     {
  84.         if ($this->players->removeElement($player)) {
  85.             // set the owning side to null (unless already changed)
  86.             if ($player->getCountry() === $this) {
  87.                 $player->setCountry(null);
  88.             }
  89.         }
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection|User[]
  94.      */
  95.     public function getUsers(): Collection
  96.     {
  97.         return $this->users;
  98.     }
  99.     public function addUser(User $user): self
  100.     {
  101.         if (!$this->users->contains($user)) {
  102.             $this->users[] = $user;
  103.             $user->setCountry($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeUser(User $user): self
  108.     {
  109.         if ($this->users->removeElement($user)) {
  110.             // set the owning side to null (unless already changed)
  111.             if ($user->getCountry() === $this) {
  112.                 $user->setCountry(null);
  113.             }
  114.         }
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return mixed
  119.      */
  120.     public function getId()
  121.     {
  122.         return $this->id;
  123.     }
  124.     /**
  125.      * @param mixed $id
  126.      */
  127.     public function setId($id): void
  128.     {
  129.         $this->id $id;
  130.     }
  131.     /**
  132.      * @return mixed
  133.      */
  134.     public function getName()
  135.     {
  136.         return $this->name;
  137.     }
  138.     /**
  139.      * @param mixed $name
  140.      */
  141.     public function setName($name): void
  142.     {
  143.         $this->name $name;
  144.     }
  145.     /**
  146.      * @return mixed
  147.      */
  148.     public function getCode()
  149.     {
  150.         return $this->code;
  151.     }
  152.     /**
  153.      * @param mixed $code
  154.      */
  155.     public function setCode($code): void
  156.     {
  157.         $this->code $code;
  158.     }
  159.     /**
  160.      * @return mixed
  161.      */
  162.     public function getLongCode()
  163.     {
  164.         return $this->longCode;
  165.     }
  166.     /**
  167.      * @param $longCode
  168.      */
  169.     public function setLongCode($longCode): void
  170.     {
  171.         $this->longCode $longCode;
  172.     }
  173.     /**
  174.      * @return mixed
  175.      */
  176.     public function getRegion()
  177.     {
  178.         return $this->region;
  179.     }
  180.     /**
  181.      * @param mixed $region
  182.      */
  183.     public function setRegion($region): void
  184.     {
  185.         $this->region $region;
  186.     }
  187.     /**
  188.      * @return string
  189.      * @Groups({"country:list", "country:item","player:list", "player:item"})
  190.      */
  191.     public function getFlag(): ?string
  192.     {
  193.         return $this->flag;
  194.     }
  195.     /**
  196.      * @param string $flag
  197.      */
  198.     public function setFlag(string $flag): void
  199.     {
  200.         $this->flag $flag;
  201.     }
  202.     public function getSortOrder(): ?int
  203.     {
  204.         return $this->sortOrder;
  205.     }
  206.     public function setSortOrder(?int $sortOrder): self
  207.     {
  208.         $this->sortOrder $sortOrder;
  209.         return $this;
  210.     }
  211. }