<?php
namespace App\Entity;
use App\Repository\AddressRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: AddressRepository::class)]
class Address
{
const TYPE_STREET = 'street';
const TYPE_HOUSENUMBER = 'housenumber';
const TYPE_LOCALITY = 'locality';
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $type = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $street = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups([
'read:company:collection:get'
])]
private ?string $housenumber = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $locality = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups([
'read:club:collection:getCompanies',
'read:club:collection',
'read:company:collection:get',
'read:user:item:me',
'read:club:collection:getClubLocalize'
])]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups([
'read:club:collection:getCompanies',
'read:club:collection',
'read:company:collection:get'
])]
private ?string $postcode = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $citycode = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups([
'read:club:collection:getCompanies',
'read:club:collection',
'read:company:collection:get',
'read:user:item:me',
"read:claimingRequest:collection:getUserCompaniesClaimed",
'read:user:item:user:companies:management'
])]
private ?string $city = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $district = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $context = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $deptNumber = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $deptName = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $regionName = null;
#[ORM\Column(nullable: true)]
#[Groups([
'read:club:collection:getCompanies',
'read:club:collection',
'read:company:collection:get',
'read:user:item:me',
'read:club:collection:getClubLocalize'
])]
private ?float $lat = null;
#[ORM\Column(nullable: true)]
#[Groups([
'read:club:collection:getCompanies',
'read:club:collection',
'read:company:collection:get',
'read:user:item:me',
'read:club:collection:getClubLocalize'
])]
private ?float $longi = null;
#[ORM\Column(nullable: true)]
private ?float $x = null;
#[ORM\Column(nullable: true)]
private ?float $y = null;
#[ORM\OneToMany(mappedBy: 'address', targetEntity: Company::class)]
private Collection $companies;
#[ORM\OneToMany(mappedBy: 'address', targetEntity: Club::class)]
private Collection $clubs;
public function __toString(): string
{
return $this->name . ' - '.$this->getPostcode().' '.$this->city;
}
public function getCompleteAddress(): string
{
return $this->name . ' - '.$this->postcode.' '.$this->city;
}
public function __construct()
{
$this->type = self::TYPE_STREET;
$this->companies = new ArrayCollection();
$this->clubs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): self
{
$this->street = $street;
return $this;
}
public function getHousenumber(): ?string
{
return $this->housenumber;
}
public function setHousenumber(?string $housenumber): self
{
$this->housenumber = $housenumber;
return $this;
}
public function getLocality(): ?string
{
return $this->locality;
}
public function setLocality(?string $locality): self
{
$this->locality = $locality;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getPostcode(): ?string
{
return $this->postcode;
}
public function setPostcode(?string $postcode): self
{
$this->postcode = $postcode;
return $this;
}
public function getCitycode(): ?string
{
return $this->citycode;
}
public function setCitycode(?string $citycode): self
{
$this->citycode = $citycode;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getDistrict(): ?string
{
return $this->district;
}
public function setDistrict(?string $district): self
{
$this->district = $district;
return $this;
}
public function getContext(): ?string
{
return $this->context;
}
public function setContext(?string $context): self
{
$this->context = $context;
return $this;
}
public function getDeptNumber(): ?string
{
return $this->deptNumber;
}
public function setDeptNumber(?string $deptNumber): self
{
$this->deptNumber = $deptNumber;
return $this;
}
public function getDeptName(): ?string
{
return $this->deptName;
}
public function setDeptName(?string $deptName): self
{
$this->deptName = $deptName;
return $this;
}
public function getRegionName(): ?string
{
return $this->regionName;
}
public function setRegionName(?string $regionName): self
{
$this->regionName = $regionName;
return $this;
}
public function getLat(): ?float
{
return $this->lat;
}
public function setLat(?float $lat): self
{
$this->lat = $lat;
return $this;
}
public function getLongi(): ?float
{
return $this->longi;
}
public function setLongi(?float $longi): self
{
$this->longi = $longi;
return $this;
}
public function getX(): ?float
{
return $this->x;
}
public function setX(?float $x): self
{
$this->x = $x;
return $this;
}
public function getY(): ?float
{
return $this->y;
}
public function setY(?float $y): self
{
$this->y = $y;
return $this;
}
/**
* @return Collection<int, Company>
*/
public function getCompanies(): Collection
{
return $this->companies;
}
public function addCompany(Company $company): self
{
if (!$this->companies->contains($company)) {
$this->companies->add($company);
$company->setAddress($this);
}
return $this;
}
public function removeCompany(Company $company): self
{
if ($this->companies->removeElement($company)) {
// set the owning side to null (unless already changed)
if ($company->getAddress() === $this) {
$company->setAddress(null);
}
}
return $this;
}
/**
* @return Collection<int, Club>
*/
public function getClubs(): Collection
{
return $this->clubs;
}
public function addClub(Club $club): self
{
if (!$this->clubs->contains($club)) {
$this->clubs->add($club);
$club->setAddress($this);
}
return $this;
}
public function removeClub(Club $club): self
{
if ($this->clubs->removeElement($club)) {
// set the owning side to null (unless already changed)
if ($club->getAddress() === $this) {
$club->setAddress(null);
}
}
return $this;
}
}