src/Entity/Location.php line 13
<?php
namespace App\Entity;
use Symfony\Component\Uid\Ulid;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\LocationRepository;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
#[ORM\Entity(repositoryClass: LocationRepository::class)]
class Location
{
#[ORM\Id]
#[ORM\Column(type: 'ulid', unique: true)]
#[ORM\GeneratedValue(strategy: "CUSTOM")]
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
private ?Ulid $id = null;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['read:company'])]
private $country;
#[ORM\Column(type: 'string', length: 255)]
#[Groups(['read:company'])]
private $wilaya;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:company'])]
private $city;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:company'])]
private $street;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:company'])]
private $nhouse;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:company'])]
private $zipcode;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:company'])]
private $lat;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Groups(['read:company'])]
private $lon;
#[ORM\OneToOne(mappedBy: 'address', targetEntity: Child::class, cascade: ['persist', 'remove'])]
private $child;
#[ORM\OneToOne(mappedBy: 'address', targetEntity: Employee::class, cascade: ['persist', 'remove'])]
private $employee;
// TODO:: add owner here
public function __construct()
{
$this->country = "DZ";
$this->wilaya = "Boumerdès";
}
public function __toString()
{
if (!$this->wilaya)
$this->wilaya = "";
if (!$this->city)
$this->city = "";
return $this->wilaya . " " . $this->city;
}
public function getId(): ?Ulid
{
return $this->id;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getWilaya(): ?string
{
return $this->wilaya;
}
public function setWilaya(string $wilaya): self
{
$this->wilaya = $wilaya;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): self
{
$this->street = $street;
return $this;
}
public function getNhouse(): ?string
{
return $this->nhouse;
}
public function setNhouse(?string $nhouse): self
{
$this->nhouse = $nhouse;
return $this;
}
public function getZipcode(): ?string
{
return $this->zipcode;
}
public function setZipcode(?string $zipcode): self
{
$this->zipcode = $zipcode;
return $this;
}
public function getLat(): ?string
{
return $this->lat;
}
public function setLat(?string $lat): self
{
$this->lat = $lat;
return $this;
}
public function getLon(): ?string
{
return $this->lon;
}
public function setLon(?string $lon): self
{
$this->lon = $lon;
return $this;
}
public function getChild(): ?Child
{
return $this->child;
}
public function setChild(?Child $child): self
{
// unset the owning side of the relation if necessary
if ($child === null && $this->child !== null) {
$this->child->setAddress(null);
}
// set the owning side of the relation if necessary
if ($child !== null && $child->getAddress() !== $this) {
$child->setAddress($this);
}
$this->child = $child;
return $this;
}
public function getEmployee(): ?Employee
{
return $this->employee;
}
public function setEmployee(?Employee $employee): self
{
// unset the owning side of the relation if necessary
if ($employee === null && $this->employee !== null) {
$this->employee->setAddress(null);
}
// set the owning side of the relation if necessary
if ($employee !== null && $employee->getAddress() !== $this) {
$employee->setAddress($this);
}
$this->employee = $employee;
return $this;
}
}