src/Entity/Location.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use Symfony\Component\Uid\Ulid;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\LocationRepository;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
  8. #[ORM\Entity(repositoryClassLocationRepository::class)]
  9. class Location
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\Column(type'ulid'uniquetrue)]
  13.     #[ORM\GeneratedValue(strategy"CUSTOM")]
  14.     #[ORM\CustomIdGenerator(class: UlidGenerator::class)]
  15.     private ?Ulid $id null;
  16.     #[ORM\Column(type'string'length255)]
  17.     #[Groups(['read:company'])]
  18.     private $country;
  19.     #[ORM\Column(type'string'length255)]
  20.     #[Groups(['read:company'])]
  21.     private $wilaya;
  22.     #[ORM\Column(type'string'length255nullabletrue)]
  23.     #[Groups(['read:company'])]
  24.     private $city;
  25.     #[ORM\Column(type'string'length255nullabletrue)]
  26.     #[Groups(['read:company'])]
  27.     private $street;
  28.     #[ORM\Column(type'string'length255nullabletrue)]
  29.     #[Groups(['read:company'])]
  30.     private $nhouse;
  31.     #[ORM\Column(type'string'length255nullabletrue)]
  32.     #[Groups(['read:company'])]
  33.     private $zipcode;
  34.     #[ORM\Column(type'string'length255nullabletrue)]
  35.     #[Groups(['read:company'])]
  36.     private $lat;
  37.     #[ORM\Column(type'string'length255nullabletrue)]
  38.     #[Groups(['read:company'])]
  39.     private $lon;
  40.     #[ORM\OneToOne(mappedBy'address'targetEntityChild::class, cascade: ['persist''remove'])]
  41.     private $child;
  42.     #[ORM\OneToOne(mappedBy'address'targetEntityEmployee::class, cascade: ['persist''remove'])]
  43.     private $employee;
  44.     // TODO:: add owner here
  45.     public function __construct()
  46.     {
  47.         $this->country "DZ";
  48.         $this->wilaya "Boumerdès";
  49.     }
  50.     public function __toString()
  51.     {
  52.         if (!$this->wilaya)
  53.             $this->wilaya "";
  54.         if (!$this->city)
  55.             $this->city "";
  56.         return $this->wilaya " " $this->city;
  57.     }
  58.     public function getId(): ?Ulid
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getCountry(): ?string
  63.     {
  64.         return $this->country;
  65.     }
  66.     public function setCountry(string $country): self
  67.     {
  68.         $this->country $country;
  69.         return $this;
  70.     }
  71.     public function getWilaya(): ?string
  72.     {
  73.         return $this->wilaya;
  74.     }
  75.     public function setWilaya(string $wilaya): self
  76.     {
  77.         $this->wilaya $wilaya;
  78.         return $this;
  79.     }
  80.     public function getCity(): ?string
  81.     {
  82.         return $this->city;
  83.     }
  84.     public function setCity(?string $city): self
  85.     {
  86.         $this->city $city;
  87.         return $this;
  88.     }
  89.     public function getStreet(): ?string
  90.     {
  91.         return $this->street;
  92.     }
  93.     public function setStreet(?string $street): self
  94.     {
  95.         $this->street $street;
  96.         return $this;
  97.     }
  98.     public function getNhouse(): ?string
  99.     {
  100.         return $this->nhouse;
  101.     }
  102.     public function setNhouse(?string $nhouse): self
  103.     {
  104.         $this->nhouse $nhouse;
  105.         return $this;
  106.     }
  107.     public function getZipcode(): ?string
  108.     {
  109.         return $this->zipcode;
  110.     }
  111.     public function setZipcode(?string $zipcode): self
  112.     {
  113.         $this->zipcode $zipcode;
  114.         return $this;
  115.     }
  116.     public function getLat(): ?string
  117.     {
  118.         return $this->lat;
  119.     }
  120.     public function setLat(?string $lat): self
  121.     {
  122.         $this->lat $lat;
  123.         return $this;
  124.     }
  125.     public function getLon(): ?string
  126.     {
  127.         return $this->lon;
  128.     }
  129.     public function setLon(?string $lon): self
  130.     {
  131.         $this->lon $lon;
  132.         return $this;
  133.     }
  134.     public function getChild(): ?Child
  135.     {
  136.         return $this->child;
  137.     }
  138.     public function setChild(?Child $child): self
  139.     {
  140.         // unset the owning side of the relation if necessary
  141.         if ($child === null && $this->child !== null) {
  142.             $this->child->setAddress(null);
  143.         }
  144.         // set the owning side of the relation if necessary
  145.         if ($child !== null && $child->getAddress() !== $this) {
  146.             $child->setAddress($this);
  147.         }
  148.         $this->child $child;
  149.         return $this;
  150.     }
  151.     public function getEmployee(): ?Employee
  152.     {
  153.         return $this->employee;
  154.     }
  155.     public function setEmployee(?Employee $employee): self
  156.     {
  157.         // unset the owning side of the relation if necessary
  158.         if ($employee === null && $this->employee !== null) {
  159.             $this->employee->setAddress(null);
  160.         }
  161.         // set the owning side of the relation if necessary
  162.         if ($employee !== null && $employee->getAddress() !== $this) {
  163.             $employee->setAddress($this);
  164.         }
  165.         $this->employee $employee;
  166.         return $this;
  167.     }
  168. }