src/Entity/Country.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\CountryRepository")
  8.  */
  9. class Country
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=2, unique=true)
  19.      */
  20.     private $code;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\Column(type="boolean")
  27.      */
  28.     private $is_eu;
  29.     /**
  30.      * @ORM\Column(type="boolean")
  31.      */
  32.     private $is_active true;
  33.     /**
  34.      * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="Country")
  35.      */
  36.     private $users;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity="App\Entity\Payment", mappedBy="country")
  39.      */
  40.     private $payments;
  41.     /**
  42.      * Country constructor.
  43.      * @param $id
  44.      * @param $code
  45.      * @param $name
  46.      * @param $is_eu
  47.      */
  48.     public function __construct($code$name$is_eu)
  49.     {
  50.         $this->code $code;
  51.         $this->name $name;
  52.         $this->is_eu $is_eu;
  53.         $this->users = new ArrayCollection();
  54.         $this->payments = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getCode(): ?string
  61.     {
  62.         return $this->code;
  63.     }
  64.     public function setCode(string $code): self
  65.     {
  66.         $this->code $code;
  67.         return $this;
  68.     }
  69.     public function getName(): ?string
  70.     {
  71.         return $this->name;
  72.     }
  73.     public function setName(string $name): self
  74.     {
  75.         $this->name $name;
  76.         return $this;
  77.     }
  78.     public function getIsEu(): ?bool
  79.     {
  80.         return $this->is_eu;
  81.     }
  82.     public function setIsEu(bool $is_eu): self
  83.     {
  84.         $this->is_eu $is_eu;
  85.         return $this;
  86.     }
  87.     public function getIsActive(): ?bool
  88.     {
  89.         return $this->is_active;
  90.     }
  91.     public function setIsActive(bool $is_active): self
  92.     {
  93.         $this->is_active $is_active;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @return Collection|User[]
  98.      */
  99.     public function getUsers(): Collection
  100.     {
  101.         return $this->users;
  102.     }
  103.     public function addUser(User $user): self
  104.     {
  105.         if (!$this->users->contains($user)) {
  106.             $this->users[] = $user;
  107.             $user->setCountry($this);
  108.         }
  109.         return $this;
  110.     }
  111.     public function removeUser(User $user): self
  112.     {
  113.         if ($this->users->contains($user)) {
  114.             $this->users->removeElement($user);
  115.             // set the owning side to null (unless already changed)
  116.             if ($user->getCountry() === $this) {
  117.                 $user->setCountry(null);
  118.             }
  119.         }
  120.         return $this;
  121.     }
  122.     /**
  123.      * @return Collection|Payment[]
  124.      */
  125.     public function getPayments(): Collection
  126.     {
  127.         return $this->payments;
  128.     }
  129.     public function addPayment(Payment $payment): self
  130.     {
  131.         if (!$this->payments->contains($payment)) {
  132.             $this->payments[] = $payment;
  133.             $payment->setCountry($this);
  134.         }
  135.         return $this;
  136.     }
  137.     public function removePayment(Payment $payment): self
  138.     {
  139.         if ($this->payments->contains($payment)) {
  140.             $this->payments->removeElement($payment);
  141.             // set the owning side to null (unless already changed)
  142.             if ($payment->getCountry() === $this) {
  143.                 $payment->setCountry(null);
  144.             }
  145.         }
  146.         return $this;
  147.     }
  148. }