src/Entity/Country.php line 13

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. /**
  8.  * @ORM\Entity(repositoryClass=CountryRepository::class)
  9.  */
  10. class Country
  11. {
  12.     const COUNTRY_ROMANIA 1;
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private string $name;
  23.     /**
  24.      * @ORM\Column(type="boolean" ,options={"default":false})
  25.      */
  26.     private bool $isDefault false;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity=Company::class, mappedBy="country")
  29.      */
  30.     private $companies;
  31.     public function __construct()
  32.     {
  33.         $this->companies = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function __toString(): string
  40.     {
  41.         return $this->getName();
  42.     }
  43.     public function getName(): ?string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function setName(string $name): self
  48.     {
  49.         $this->name $name;
  50.         return $this;
  51.     }
  52.     public function isIsDefault(): ?bool
  53.     {
  54.         return $this->isDefault;
  55.     }
  56.     public function setIsDefault(bool $isDefault): self
  57.     {
  58.         $this->isDefault $isDefault;
  59.         return $this;
  60.     }
  61.     /**
  62.      * @return Collection<int, Company>
  63.      */
  64.     public function getCompanies(): Collection
  65.     {
  66.         return $this->companies;
  67.     }
  68.     public function addCompany(Company $company): self
  69.     {
  70.         if (!$this->companies->contains($company)) {
  71.             $this->companies[] = $company;
  72.             $company->setCountry($this);
  73.         }
  74.         return $this;
  75.     }
  76.     public function removeCompany(Company $company): self
  77.     {
  78.         if ($this->companies->removeElement($company)) {
  79.             // set the owning side to null (unless already changed)
  80.             if ($company->getCountry() === $this) {
  81.                 $company->setCountry(null);
  82.             }
  83.         }
  84.         return $this;
  85.     }
  86. }