src/Entity/TypePrestation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TypePrestationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ORM\Entity(repositoryClass=TypePrestationRepository::class)
  10.  */
  11. class TypePrestation
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      * @Groups("location:read")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      * @Groups("location:read")
  23.      */
  24.     private $label;
  25.     /**
  26.      * @ORM\OneToMany(targetEntity=Product::class, mappedBy="typePrestation")
  27.      */
  28.     private $products;
  29.     public function __construct()
  30.     {
  31.         $this->products = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getLabel(): ?string
  38.     {
  39.         return $this->label;
  40.     }
  41.     public function setLabel(string $label): self
  42.     {
  43.         $this->label $label;
  44.         return $this;
  45.     }
  46.     /**
  47.      * @return Collection|Product[]
  48.      */
  49.     public function getProducts(): Collection
  50.     {
  51.         return $this->products;
  52.     }
  53.     public function addProduct(Product $product): self
  54.     {
  55.         if (!$this->products->contains($product)) {
  56.             $this->products[] = $product;
  57.             $product->setTypePrestation($this);
  58.         }
  59.         return $this;
  60.     }
  61.     public function removeProduct(Product $product): self
  62.     {
  63.         if ($this->products->removeElement($product)) {
  64.             // set the owning side to null (unless already changed)
  65.             if ($product->getTypePrestation() === $this) {
  66.                 $product->setTypePrestation(null);
  67.             }
  68.         }
  69.         return $this;
  70.     }
  71.     public function __toString()
  72.     {
  73.         return $this->getLabel();
  74.     }
  75. }