src/Entity/JobLevel.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Item\Item;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\JobLevelRepository;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. /**
  9.  * @ORM\Entity(repositoryClass=JobLevelRepository::class)
  10.  */
  11. class JobLevel
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="integer", nullable=true)
  21.      */
  22.     private $position;
  23.     /**
  24.      * @ORM\Column(type="boolean", nullable=true)
  25.      */
  26.     private $active;
  27.     /**
  28.      * @ORM\ManyToMany(targetEntity=Item::class, cascade={"persist","refresh"})
  29.      */
  30.     private $item;
  31.     public function __construct()
  32.     {   
  33.         $this->item = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getPosition(): ?int
  40.     {
  41.         return $this->position;
  42.     }
  43.     public function setPosition(?int $position): self
  44.     {
  45.         $this->position = $position;
  46.         return $this;
  47.     }
  48.     public function getActive(): ?bool
  49.     {
  50.         return $this->active;
  51.     }
  52.     public function setActive(?bool $active): self
  53.     {
  54.         $this->active = $active;
  55.         return $this;
  56.     }
  57.    /**
  58.      * @return Collection|Item[]
  59.      */
  60.     public function getItems(): Collection
  61.     {
  62.         return $this->item;
  63.     }
  64.     public function addItem(Item $item): self
  65.     {
  66.         if (!$this->item->contains($item)) {
  67.             $this->item[] = $item;
  68.             $item->addJobLevel($this);
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeItem(Item $item): self
  73.     {
  74.         if ($this->item->removeElement($item)) {
  75.             // set the owning side to null (unless already changed)
  76.             if ($item->getJobLevels() === $this) {
  77.                 $item->removeJobLevel(null);
  78.             }
  79.         }
  80.         return $this;
  81.     }
  82. }