src/Entity/WasteType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\isActif;
  4. use App\Repository\WasteTypeRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=WasteTypeRepository::class)
  10.  */
  11. class WasteType
  12. {
  13.     use isActif;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\ManyToMany(targetEntity=Collect::class, mappedBy="wasteType")
  26.      */
  27.     private $collects;
  28.     /**
  29.      * @ORM\ManyToMany(targetEntity=Equipment::class, mappedBy="waste_type")
  30.      */
  31.     private $equipment;
  32.     /**
  33.      * @ORM\OneToMany(targetEntity=Contract::class, mappedBy="waste")
  34.      */
  35.     private $contracts;
  36.     public function __construct()
  37.     {
  38.         $this->collects = new ArrayCollection();
  39.         $this->equipment = new ArrayCollection();
  40.         $this->contracts = new ArrayCollection();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getName(): ?string
  47.     {
  48.         return $this->name;
  49.     }
  50.     public function setName(string $name): self
  51.     {
  52.         $this->name $name;
  53.         return $this;
  54.     }
  55.     /**
  56.      * @return Collection|Collect[]
  57.      */
  58.     public function getCollects(): Collection
  59.     {
  60.         return $this->collects;
  61.     }
  62.     public function addCollect(Collect $collect): self
  63.     {
  64.         if (! $this->collects->contains($collect)) {
  65.             $this->collects[] = $collect;
  66.             $collect->addWasteType($this);
  67.         }
  68.         return $this;
  69.     }
  70.     public function removeCollect(Collect $collect): self
  71.     {
  72.         if ($this->collects->removeElement($collect)) {
  73.             $collect->removeWasteType($this);
  74.         }
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection|Equipment[]
  79.      */
  80.     public function getEquipment(): Collection
  81.     {
  82.         return $this->equipment;
  83.     }
  84.     public function addEquipment(Equipment $equipment): self
  85.     {
  86.         if (! $this->equipment->contains($equipment)) {
  87.             $this->equipment[] = $equipment;
  88.             $equipment->addWasteType($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeEquipment(Equipment $equipment): self
  93.     {
  94.         if ($this->equipment->removeElement($equipment)) {
  95.             $equipment->removeWasteType($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function __toString(): string
  100.     {
  101.         return $this->name;
  102.     }
  103.     /**
  104.      * @return Collection|Contract[]
  105.      */
  106.     public function getContracts(): Collection
  107.     {
  108.         return $this->contracts;
  109.     }
  110.     public function addContract(Contract $contract): self
  111.     {
  112.         if (! $this->contracts->contains($contract)) {
  113.             $this->contracts[] = $contract;
  114.             $contract->setWaste($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeContract(Contract $contract): self
  119.     {
  120.         if ($this->contracts->removeElement($contract)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($contract->getWaste() === $this) {
  123.                 $contract->setWaste(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128. }