src/Entity/Address.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AddressRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=AddressRepository::class)
  9.  */
  10. class Address
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $zipCode;
  22.         /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $street;
  26.     
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $city;
  31.     /**
  32.      * @ORM\Column(type="string", length=255)
  33.      */
  34.     private $placeType;
  35.     /**
  36.      * @ORM\OneToMany(targetEntity=Properties::class, mappedBy="address", cascade={"remove"})
  37.      */
  38.     private $properties;
  39.     /**
  40.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="address")
  41.      */
  42.     private $users;
  43.     /**
  44.      * @ORM\Column(type="integer")
  45.      */
  46.     private $placeNumber;
  47.     public function __construct()
  48.     {
  49.         $this->properties = new ArrayCollection();
  50.         $this->users = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getZipCode(): ?int
  57.     {
  58.         return $this->zipCode;
  59.     }
  60.     public function setZipCode(int $zipCode): self
  61.     {
  62.         $this->zipCode $zipCode;
  63.         return $this;
  64.     }
  65.     public function getCity(): ?string
  66.     {
  67.         return $this->city;
  68.     }
  69.     public function setCity(string $city): self
  70.     {
  71.         $this->city $city;
  72.         return $this;
  73.     }
  74.     public function getStreet(): ?string
  75.     {
  76.         return $this->street;
  77.     }
  78.     public function setStreet(string $street): self
  79.     {
  80.         $this->street $street;
  81.         return $this;
  82.     }
  83.     public function getPlaceType(): ?string
  84.     {
  85.         return $this->placeType;
  86.     }
  87.     public function setPlaceType(string $placeType): self
  88.     {
  89.         $this->placeType $placeType;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection<int, Properties>
  94.      */
  95.     public function getProperties(): Collection
  96.     {
  97.         return $this->properties;
  98.     }
  99.     public function addProperty(Properties $property): self
  100.     {
  101.         if (!$this->properties->contains($property)) {
  102.             $this->properties[] = $property;
  103.             $property->setAddress($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeProperty(Properties $property): self
  108.     {
  109.         if ($this->properties->removeElement($property)) {
  110.             // set the owning side to null (unless already changed)
  111.             if ($property->getAddress() === $this) {
  112.                 $property->setAddress(null);
  113.             }
  114.         }
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return Collection<int, User>
  119.      */
  120.     public function getUsers(): Collection
  121.     {
  122.         return $this->users;
  123.     }
  124.     public function addUser(User $user): self
  125.     {
  126.         if (!$this->users->contains($user)) {
  127.             $this->users[] = $user;
  128.             $user->setAddress($this);
  129.         }
  130.         return $this;
  131.     }
  132.     public function removeUser(User $user): self
  133.     {
  134.         if ($this->users->removeElement($user)) {
  135.             // set the owning side to null (unless already changed)
  136.             if ($user->getAddress() === $this) {
  137.                 $user->setAddress(null);
  138.             }
  139.         }
  140.         return $this;
  141.     }
  142.     public function getPlaceNumber(): ?int
  143.     {
  144.         return $this->placeNumber;
  145.     }
  146.     public function setPlaceNumber(int $placeNumber): self
  147.     {
  148.         $this->placeNumber $placeNumber;
  149.         return $this;
  150.     }
  151.     public function __toString(): string
  152.     {
  153.         return sprintf(
  154.             '%d %s, %s %d',
  155.             $this->getPlaceNumber(),
  156.             $this->getPlaceType(),
  157.             $this->getStreet(),
  158.             $this->getCity(),
  159.             $this->getZipCode()
  160.         );
  161.     }
  162. }