src/Admin/Modules/MeetingScheduler/Entity/MeetingCategory.php line 16

  1. <?php
  2. namespace App\Admin\Modules\MeetingScheduler\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. use Gedmo\Mapping\Annotation as Gedmo;
  8. use App\Modules\User\Entity\User;
  9. /**
  10.  * @ORM\Table(name="meeting_category", indexes={@ORM\Index(columns={"name"}), @ORM\Index(columns={"position"})})
  11.  * @ORM\Entity(repositoryClass="App\Admin\Modules\MeetingScheduler\Repository\MeetingCategoryRepository")
  12.  */
  13. class MeetingCategory
  14. {
  15.     /**
  16.      * @var int
  17.      *
  18.      * @ORM\Column(type="bigint", options={"unsigned"=true}))
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue(strategy="AUTO")
  21.      */
  22.     protected $id;
  23.     /**
  24.      * @var \App\Admin\Modules\MeetingScheduler\Entity\MeetingCategory
  25.      *
  26.      * @ORM\ManyToOne(targetEntity="App\Admin\Modules\MeetingScheduler\Entity\MeetingCategory", inversedBy="subcategories")
  27.      * @ORM\JoinColumns({
  28.      *   @ORM\JoinColumn(name="id_parent", referencedColumnName="id", nullable=true, onDelete="CASCADE")
  29.      * })
  30.      */
  31.     private $parent;    
  32.     
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(name="name", type="string", length=255, nullable=false)
  37.      */
  38.     private $name;
  39.     
  40.     /**
  41.      * @var bool
  42.      *
  43.      * @ORM\Column(name="free_of_charge", type="boolean", nullable=true)
  44.      */
  45.     private $freeOfCharge;
  46.     
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(name="price", type="decimal", precision=14, scale=2, nullable=true)
  51.      */
  52.     private $price;
  53.     /**
  54.      * @var double
  55.      *
  56.      * @ORM\Column(name="vat", type="float", nullable=true)
  57.      */
  58.     private $vat;
  59.     /**
  60.      * @var int
  61.      *
  62.      * @ORM\Column(name="duration", type="integer", nullable=true)
  63.      */
  64.     private $duration;    
  65.     
  66.     /**
  67.      * @var int
  68.      *
  69.      * @ORM\Column(name="position", type="integer", nullable=false)
  70.      */
  71.     private $position;     
  72.     
  73.     /**
  74.      * @var \App\Modules\User\Entity\User
  75.      *
  76.      * @ORM\ManyToOne(targetEntity="App\Modules\User\Entity\User")
  77.      * @ORM\JoinColumns({
  78.      *   @ORM\JoinColumn(name="id_added_by", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  79.      * })
  80.      */
  81.     private $addedBy;
  82.     
  83.     /**
  84.      * @var \App\Admin\Modules\MeetingScheduler\Entity\MeetingCategory
  85.      *
  86.      * @ORM\OneToMany(targetEntity="App\Admin\Modules\MeetingScheduler\Entity\MeetingCategory", mappedBy="parent", cascade={"persist"}, orphanRemoval=true)
  87.      * @ORM\OrderBy({"position"="ASC"})
  88.      */
  89.     private $subcategories;
  90.     public function __construct()
  91.     {
  92.         $this->subcategories = new ArrayCollection();
  93.     }
  94.     
  95.     public function __toString()
  96.     {
  97.         return $this->name;
  98.     }
  99.     public function getId(): ?string
  100.     {
  101.         return $this->id;
  102.     }
  103.     
  104.     private $_displayName;
  105.     public function setDisplayName($name)
  106.     {
  107.         $this->_displayName $name;
  108.     }
  109.     
  110.     public function getDisplayName()
  111.     {
  112.         return $this->_displayName ?? $this->name;
  113.     }
  114.     public function getName(): ?string
  115.     {
  116.         return $this->name;
  117.     }
  118.     public function setName(string $name): self
  119.     {
  120.         $this->name $name;
  121.         return $this;
  122.     }
  123.     public function getPosition(): ?int
  124.     {
  125.         return $this->position;
  126.     }
  127.     public function setPosition(int $position): self
  128.     {
  129.         $this->position $position;
  130.         return $this;
  131.     }
  132.     public function getParent(): ?self
  133.     {
  134.         return $this->parent;
  135.     }
  136.     public function setParent(?self $parent): self
  137.     {
  138.         $this->parent $parent;
  139.         return $this;
  140.     }
  141.     public function getAddedBy(): ?User
  142.     {
  143.         return $this->addedBy;
  144.     }
  145.     public function setAddedBy(?User $addedBy): self
  146.     {
  147.         $this->addedBy $addedBy;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @return Collection<int, MeetingCategory>
  152.      */
  153.     public function getSubcategories(): Collection
  154.     {
  155.         return $this->subcategories;
  156.     }
  157.     public function addSubcategory(MeetingCategory $subcategory): self
  158.     {
  159.         if (!$this->subcategories->contains($subcategory)) {
  160.             $this->subcategories->add($subcategory);
  161.             $subcategory->setParent($this);
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeSubcategory(MeetingCategory $subcategory): self
  166.     {
  167.         if ($this->subcategories->removeElement($subcategory)) {
  168.             // set the owning side to null (unless already changed)
  169.             if ($subcategory->getParent() === $this) {
  170.                 $subcategory->setParent(null);
  171.             }
  172.         }
  173.         return $this;
  174.     }
  175.     public function getPrice(): ?string
  176.     {
  177.         return $this->price;
  178.     }
  179.     public function setPrice(?string $price): self
  180.     {
  181.         $this->price $price;
  182.         return $this;
  183.     }
  184.     public function getVat(): ?float
  185.     {
  186.         return $this->vat;
  187.     }
  188.     public function setVat(?float $vat): self
  189.     {
  190.         $this->vat $vat;
  191.         return $this;
  192.     }
  193.     public function getDuration(): ?int
  194.     {
  195.         return $this->duration;
  196.     }
  197.     public function setDuration(?int $duration): self
  198.     {
  199.         $this->duration $duration;
  200.         return $this;
  201.     }
  202.     public function getFreeOfCharge(): ?bool
  203.     {
  204.         return $this->freeOfCharge;
  205.     }
  206.     public function setFreeOfCharge(?bool $freeOfCharge): self
  207.     {
  208.         $this->freeOfCharge $freeOfCharge;
  209.         return $this;
  210.     }    
  211. }