src/Entity/Country.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CountryRepository;
  4. use App\Traits\TimeStampTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassCountryRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. class Country
  11. {
  12.     use TimeStampTrait;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length100)]
  18.     private ?string $code null;
  19.     #[ORM\Column(length10nullabletrue)]
  20.     private ?string $countryCode null;
  21.     #[ORM\Column(length100nullabletrue)]
  22.     private ?string $name null;
  23.     #[ORM\Column(length10nullabletrue)]
  24.     private ?string $isoCode null;
  25.     #[ORM\ManyToOne(inversedBy'countries')]
  26.     private ?User $createdBy null;
  27.     #[ORM\OneToMany(mappedBy'country'targetEntityProvince::class)]
  28.     private Collection $provinces;
  29.     #[ORM\OneToMany(mappedBy'country'targetEntityResidence::class)]
  30.     private Collection $residences;
  31.     #[ORM\Column(nullabletrue)]
  32.     private ?bool $status null;
  33.     #[ORM\OneToMany(mappedBy'country'targetEntityEntreprise::class)]
  34.     private Collection $entreprises;
  35.     #[ORM\OneToMany(mappedBy'country'targetEntityUser::class)]
  36.     private Collection $users;
  37.     public function __construct()
  38.     {
  39.         $this->provinces = new ArrayCollection();
  40.         $this->residences = new ArrayCollection();
  41.         $this->entreprises = new ArrayCollection();
  42.         $this->users = new ArrayCollection();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getCode(): ?string
  49.     {
  50.         return $this->code;
  51.     }
  52.     public function setCode(string $code): static
  53.     {
  54.         $this->code $code;
  55.         return $this;
  56.     }
  57.     public function getCountryCode(): ?string
  58.     {
  59.         return $this->countryCode;
  60.     }
  61.     public function setCountryCode(?string $countryCode): static
  62.     {
  63.         $this->countryCode $countryCode;
  64.         return $this;
  65.     }
  66.     public function getName(): ?string
  67.     {
  68.         return $this->name;
  69.     }
  70.     public function setName(?string $name): static
  71.     {
  72.         $this->name $name;
  73.         return $this;
  74.     }
  75.     public function getIsoCode(): ?string
  76.     {
  77.         return $this->isoCode;
  78.     }
  79.     public function setIsoCode(?string $isoCode): static
  80.     {
  81.         $this->isoCode $isoCode;
  82.         return $this;
  83.     }
  84.     public function getCreatedBy(): ?User
  85.     {
  86.         return $this->createdBy;
  87.     }
  88.     public function setCreatedBy(?User $createdBy): static
  89.     {
  90.         $this->createdBy $createdBy;
  91.         return $this;
  92.     }
  93.     /**
  94.      * @return Collection<int, Province>
  95.      */
  96.     public function getProvinces(): Collection
  97.     {
  98.         return $this->provinces;
  99.     }
  100.     public function addProvince(Province $province): static
  101.     {
  102.         if (!$this->provinces->contains($province)) {
  103.             $this->provinces->add($province);
  104.             $province->setCountry($this);
  105.         }
  106.         return $this;
  107.     }
  108.     public function removeProvince(Province $province): static
  109.     {
  110.         if ($this->provinces->removeElement($province)) {
  111.             // set the owning side to null (unless already changed)
  112.             if ($province->getCountry() === $this) {
  113.                 $province->setCountry(null);
  114.             }
  115.         }
  116.         return $this;
  117.     }
  118.     /**
  119.      * @return Collection<int, Residence>
  120.      */
  121.     public function getResidences(): Collection
  122.     {
  123.         return $this->residences;
  124.     }
  125.     public function addResidence(Residence $residence): static
  126.     {
  127.         if (!$this->residences->contains($residence)) {
  128.             $this->residences->add($residence);
  129.             $residence->setCountry($this);
  130.         }
  131.         return $this;
  132.     }
  133.     public function removeResidence(Residence $residence): static
  134.     {
  135.         if ($this->residences->removeElement($residence)) {
  136.             // set the owning side to null (unless already changed)
  137.             if ($residence->getCountry() === $this) {
  138.                 $residence->setCountry(null);
  139.             }
  140.         }
  141.         return $this;
  142.     }
  143.     public function __toString(): string
  144.     {
  145.         return $this->name;
  146.     }
  147.     public function isStatus(): ?bool
  148.     {
  149.         return $this->status;
  150.     }
  151.     public function setStatus(?bool $status): static
  152.     {
  153.         $this->status $status;
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return Collection<int, Entreprise>
  158.      */
  159.     public function getEntreprises(): Collection
  160.     {
  161.         return $this->entreprises;
  162.     }
  163.     public function addEntreprise(Entreprise $entreprise): static
  164.     {
  165.         if (!$this->entreprises->contains($entreprise)) {
  166.             $this->entreprises->add($entreprise);
  167.             $entreprise->setCountry($this);
  168.         }
  169.         return $this;
  170.     }
  171.     public function removeEntreprise(Entreprise $entreprise): static
  172.     {
  173.         if ($this->entreprises->removeElement($entreprise)) {
  174.             // set the owning side to null (unless already changed)
  175.             if ($entreprise->getCountry() === $this) {
  176.                 $entreprise->setCountry(null);
  177.             }
  178.         }
  179.         return $this;
  180.     }
  181.     /**
  182.      * @return Collection<int, User>
  183.      */
  184.     public function getUsers(): Collection
  185.     {
  186.         return $this->users;
  187.     }
  188.     public function addUser(User $user): static
  189.     {
  190.         if (!$this->users->contains($user)) {
  191.             $this->users->add($user);
  192.             $user->setCountry($this);
  193.         }
  194.         return $this;
  195.     }
  196.     public function removeUser(User $user): static
  197.     {
  198.         if ($this->users->removeElement($user)) {
  199.             // set the owning side to null (unless already changed)
  200.             if ($user->getCountry() === $this) {
  201.                 $user->setCountry(null);
  202.             }
  203.         }
  204.         return $this;
  205.     }
  206. }