src/Entity/ShippingAmount.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ShippingAmountRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. /**
  10.  * @ORM\Entity(repositoryClass=ShippingAmountRepository::class)
  11.  * @UniqueEntity(
  12.  *  fields="amount",
  13.  *  message="Cette categorie existe "
  14.  * )
  15.  */
  16. class ShippingAmount
  17. {
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="integer")
  26.      */
  27.     private $amount;
  28.     /**
  29.      * @ORM\OneToMany(targetEntity=Street::class, mappedBy="shippingAmount")
  30.      */
  31.     private $street;
  32.     public function __construct()
  33.     {
  34.         $this->street = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getAmount(): ?int
  41.     {
  42.         return $this->amount;
  43.     }
  44.     public function setAmount(int $amount): self
  45.     {
  46.         $this->amount $amount;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection|Street[]
  51.      */
  52.     public function getStreet(): Collection
  53.     {
  54.         return $this->street;
  55.     }
  56.     public function addStreet(Street $street): self
  57.     {
  58.         if (!$this->street->contains($street)) {
  59.             $this->street[] = $street;
  60.             $street->setShippingAmount($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeStreet(Street $street): self
  65.     {
  66.         if ($this->street->removeElement($street)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($street->getShippingAmount() === $this) {
  69.                 $street->setShippingAmount(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74. }