<?php
namespace App\Entity;
use App\Repository\AddressRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=AddressRepository::class)
*/
class Address
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="integer")
*/
private $zipCode;
/**
* @ORM\Column(type="string", length=255)
*/
private $street;
/**
* @ORM\Column(type="string", length=255)
*/
private $city;
/**
* @ORM\Column(type="string", length=255)
*/
private $placeType;
/**
* @ORM\OneToMany(targetEntity=Properties::class, mappedBy="address", cascade={"remove"})
*/
private $properties;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="address")
*/
private $users;
/**
* @ORM\Column(type="integer")
*/
private $placeNumber;
public function __construct()
{
$this->properties = new ArrayCollection();
$this->users = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getZipCode(): ?int
{
return $this->zipCode;
}
public function setZipCode(int $zipCode): self
{
$this->zipCode = $zipCode;
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 getPlaceType(): ?string
{
return $this->placeType;
}
public function setPlaceType(string $placeType): self
{
$this->placeType = $placeType;
return $this;
}
/**
* @return Collection<int, Properties>
*/
public function getProperties(): Collection
{
return $this->properties;
}
public function addProperty(Properties $property): self
{
if (!$this->properties->contains($property)) {
$this->properties[] = $property;
$property->setAddress($this);
}
return $this;
}
public function removeProperty(Properties $property): self
{
if ($this->properties->removeElement($property)) {
// set the owning side to null (unless already changed)
if ($property->getAddress() === $this) {
$property->setAddress(null);
}
}
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setAddress($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getAddress() === $this) {
$user->setAddress(null);
}
}
return $this;
}
public function getPlaceNumber(): ?int
{
return $this->placeNumber;
}
public function setPlaceNumber(int $placeNumber): self
{
$this->placeNumber = $placeNumber;
return $this;
}
public function __toString(): string
{
return sprintf(
'%d %s, %s %d',
$this->getPlaceNumber(),
$this->getPlaceType(),
$this->getStreet(),
$this->getCity(),
$this->getZipCode()
);
}
}