src/Entity/Generic/Customer/Address.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Generic\Customer;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\City;
  5. use App\Entity\Website\Order\Order;
  6. use App\Entity\State;
  7. use App\Repository\Generic\Customer\AddressRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\DBAL\Types\Types;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  13. #[ORM\Entity(repositoryClassAddressRepository::class)]
  14. class Address extends BaseEntity
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\Column(type'guid'uniquetrue)]
  18.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  19.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  20.     private ?string $id;
  21.     #[ORM\ManyToOne(inversedBy'addresses')]
  22.     #[ORM\JoinColumn(nullablefalse)]
  23.     private ?Customer $customer null;
  24.     #[ORM\ManyToOne(inversedBy'addresses')]
  25.     #[ORM\JoinColumn(nullablefalse)]
  26.     private ?State $state null;
  27.     #[ORM\ManyToOne(inversedBy'addresses')]
  28.     #[ORM\JoinColumn(nullablefalse)]
  29.     private ?City $city null;
  30.     #[ORM\Column(length255)]
  31.     private ?string $address null;
  32.     #[ORM\Column(typeTypes::BIGINT)]
  33.     private ?string $postalCode null;
  34.     #[ORM\OneToMany(mappedBy'address'targetEntityOrder::class)]
  35.     private Collection $orders;
  36.     public function __construct()
  37.     {
  38.         parent::__construct();
  39.         $this->orders = new ArrayCollection();
  40.     }
  41.     public function getId(): ?string
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getCustomer(): ?Customer
  46.     {
  47.         return $this->customer;
  48.     }
  49.     public function setCustomer(?Customer $customer): static
  50.     {
  51.         $this->customer $customer;
  52.         return $this;
  53.     }
  54.     public function getState(): ?State
  55.     {
  56.         return $this->state;
  57.     }
  58.     public function setState(?State $state): static
  59.     {
  60.         $this->state $state;
  61.         return $this;
  62.     }
  63.     public function getCity(): ?City
  64.     {
  65.         return $this->city;
  66.     }
  67.     public function setCity(?City $city): static
  68.     {
  69.         $this->city $city;
  70.         return $this;
  71.     }
  72.     public function getAddress(): ?string
  73.     {
  74.         return $this->address;
  75.     }
  76.     public function setAddress(string $address): static
  77.     {
  78.         $this->address $address;
  79.         return $this;
  80.     }
  81.     public function getPostalCode(): ?string
  82.     {
  83.         return $this->postalCode;
  84.     }
  85.     public function setPostalCode(string $postalCode): static
  86.     {
  87.         $this->postalCode $postalCode;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return Collection<int, Order>
  92.      */
  93.     public function getOrders(): Collection
  94.     {
  95.         return $this->orders;
  96.     }
  97.     public function addOrder(Order $order): static
  98.     {
  99.         if (!$this->orders->contains($order)) {
  100.             $this->orders->add($order);
  101.             $order->setAddress($this);
  102.         }
  103.         return $this;
  104.     }
  105.     public function removeOrder(Order $order): static
  106.     {
  107.         if ($this->orders->removeElement($order)) {
  108.             // set the owning side to null (unless already changed)
  109.             if ($order->getAddress() === $this) {
  110.                 $order->setAddress(null);
  111.             }
  112.         }
  113.         return $this;
  114.     }
  115. }