src/Flexy/ShopBundle/Entity/Shipping/Departement.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Shipping;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Flexy\ShopBundle\Entity\Customer\CustomerAddress;
  5. use App\Repository\Flexy\ShopBundle\Entity\Shipping\DepartementRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * @ORM\Entity(repositoryClass=DepartementRepository::class)
  11.  */
  12. #[ApiResource]
  13. class Departement
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\Column(type="text", nullable=true)
  27.      */
  28.     private $description;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=City::class, inversedBy="departements")
  31.      */
  32.     private $city;
  33.     /**
  34.      * @ORM\OneToMany(targetEntity=CustomerAddress::class, mappedBy="departement")
  35.      */
  36.     private $customerAddresses;
  37.     public function __construct()
  38.     {
  39.         $this->customerAddresses = new ArrayCollection();
  40.     }
  41.     public function __toString()
  42.     {
  43.         return $this->name;
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getName(): ?string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(string $name): self
  54.     {
  55.         $this->name $name;
  56.         return $this;
  57.     }
  58.     public function getDescription(): ?string
  59.     {
  60.         return $this->description;
  61.     }
  62.     public function setDescription(?string $description): self
  63.     {
  64.         $this->description $description;
  65.         return $this;
  66.     }
  67.     public function getCity(): ?City
  68.     {
  69.         return $this->city;
  70.     }
  71.     public function setCity(?City $city): self
  72.     {
  73.         $this->city $city;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return Collection<int, CustomerAddress>
  78.      */
  79.     public function getCustomerAddresses(): Collection
  80.     {
  81.         return $this->customerAddresses;
  82.     }
  83.     public function addCustomerAddress(CustomerAddress $customerAddress): self
  84.     {
  85.         if (!$this->customerAddresses->contains($customerAddress)) {
  86.             $this->customerAddresses[] = $customerAddress;
  87.             $customerAddress->setDepartement($this);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeCustomerAddress(CustomerAddress $customerAddress): self
  92.     {
  93.         if ($this->customerAddresses->removeElement($customerAddress)) {
  94.             // set the owning side to null (unless already changed)
  95.             if ($customerAddress->getDepartement() === $this) {
  96.                 $customerAddress->setDepartement(null);
  97.             }
  98.         }
  99.         return $this;
  100.     }
  101. }