src/Admin/Modules/OnlineService/Entity/OnlineServiceCreator.php line 14

  1. <?php
  2. namespace App\Admin\Modules\OnlineService\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="online_service_creator")
  9.  * @ORM\Entity
  10.  */
  11. class OnlineServiceCreator
  12. {
  13.     /**
  14.      * @ORM\Column(type="integer")
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     private $id;
  19.     
  20.     /**
  21.      * @ORM\OneToMany(targetEntity="App\Admin\Modules\OnlineService\Entity\OnlineServiceCreatorCategory", mappedBy="creator", cascade={"persist"}, orphanRemoval=true)
  22.      * @ORM\OrderBy({"id"="ASC"})
  23.      **/
  24.     private $categories;
  25.     public function __construct()
  26.     {
  27.         $this->categories = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     /**
  34.      * @return Collection<int, OnlineServiceCreatorCategory>
  35.      */
  36.     public function getCategories(): Collection
  37.     {
  38.         return $this->categories;
  39.     }
  40.     public function addCategory(OnlineServiceCreatorCategory $category): self
  41.     {
  42.         if (!$this->categories->contains($category)) {
  43.             $this->categories->add($category);
  44.             $category->setCreator($this);
  45.         }
  46.         return $this;
  47.     }
  48.     public function removeCategory(OnlineServiceCreatorCategory $category): self
  49.     {
  50.         if ($this->categories->removeElement($category)) {
  51.             // set the owning side to null (unless already changed)
  52.             if ($category->getCreator() === $this) {
  53.                 $category->setCreator(null);
  54.             }
  55.         }
  56.         return $this;
  57.     }
  58. }