src/Entity/Equipment.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\isActif;
  4. use App\Entity\Trait\isQuantifiable;
  5. use App\Repository\EquipmentRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Doctrine\ORM\Mapping\JoinTable;
  10. /**
  11.  * @ORM\Entity(repositoryClass=EquipmentRepository::class)
  12.  */
  13. class Equipment
  14. {
  15.     use isQuantifiable;
  16.     use isActif;
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\ManyToMany(targetEntity=WasteType::class, inversedBy="equipment")
  29.      * @JoinTable(name="Equipment_Has_WasteType")
  30.      */
  31.     private $waste_type;
  32.     /**
  33.      * @ORM\OneToMany(targetEntity=ContractHasEquipment::class, mappedBy="equipment")
  34.      */
  35.     private $contractHasEquipment;
  36.     public function __construct()
  37.     {
  38.         $this->waste_type = new ArrayCollection();
  39.         $this->contractHasEquipment = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): self
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54.     /**
  55.      * @return Collection|WasteType[]
  56.      */
  57.     public function getWasteType(): Collection
  58.     {
  59.         return $this->waste_type;
  60.     }
  61.     public function addWasteType(WasteType $wasteType): self
  62.     {
  63.         if (! $this->waste_type->contains($wasteType)) {
  64.             $this->waste_type[] = $wasteType;
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeWasteType(WasteType $wasteType): self
  69.     {
  70.         $this->waste_type->removeElement($wasteType);
  71.         return $this;
  72.     }
  73.     public function __toString(): string
  74.     {
  75.         return $this->getName() . ' ' $this->getQuantity() . ' ' $this->getMetric();
  76.     }
  77.     /**
  78.      * @return Collection|ContractHasEquipment[]
  79.      */
  80.     public function getContractHasEquipment(): Collection
  81.     {
  82.         return $this->contractHasEquipment;
  83.     }
  84.     public function addContractHasEquipment(ContractHasEquipment $contractHasEquipment): self
  85.     {
  86.         if (! $this->contractHasEquipment->contains($contractHasEquipment)) {
  87.             $this->contractHasEquipment[] = $contractHasEquipment;
  88.             $contractHasEquipment->setEquipment($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeContractHasEquipment(ContractHasEquipment $contractHasEquipment): self
  93.     {
  94.         if ($this->contractHasEquipment->removeElement($contractHasEquipment)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($contractHasEquipment->getEquipment() === $this) {
  97.                 $contractHasEquipment->setEquipment(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102. }