src/Entity/FaqCategory.php line 19

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
  9. /**
  10.  * Category
  11.  *
  12.  * @ORM\Table(name="faq_category")
  13.  * @ORM\Entity(repositoryClass="App\Repository\FaqCategoryRepository")
  14.  */
  15. class FaqCategory // implements SluggableInterface
  16. {
  17. //     use SluggableTrait;
  18.     /**
  19.      * @var integer
  20.      *
  21.      * @ORM\Column(name="id", type="integer")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @var string
  28.      *
  29.      * @ORM\Column(name="name", type="string", length=255)
  30.      */
  31.     private $name;
  32.     /**
  33.      * @var integer
  34.      *
  35.      * @ORM\Column(name="list_order", type="integer")
  36.      */
  37.     private $listOrder 1;
  38.     /**
  39.      * @var boolean
  40.      *
  41.      * @ORM\Column(name="active", type="boolean")
  42.      */
  43.     private $active;
  44.     /**
  45.      * @var string
  46.      *
  47.      * @ORM\Column(name="idioma", type="string", length=255, nullable=true)
  48.      */
  49.     private $idioma="es";
  50.     
  51.     /**
  52.      * @var Collection
  53.      * @ORM\OneToMany(targetEntity="Faq", mappedBy="category" , cascade={"persist"}, orphanRemoval=true)
  54.      */
  55.     protected $faqs;
  56.     
  57.     
  58.     /**
  59.      * @var string
  60.      *
  61.      * @ORM\Column(name="slug", type="string", length=255, nullable=true)
  62.      */
  63.     private $slug;
  64.         
  65.     public function __construct()
  66.     {
  67.         $this->items = new ArrayCollection();
  68.         $this->faqs = new ArrayCollection();
  69.     }  
  70.     public function __toString()
  71.     {
  72.         return $this->name;
  73.     }
  74.     
  75.     public function getSluggableFields(): array
  76.     {
  77.         return ['name'];
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getName(): ?string
  84.     {
  85.         return $this->name;
  86.     }
  87.     public function setName(string $name): self
  88.     {
  89.         $this->name $name;
  90.         return $this;
  91.     }
  92.     public function getListOrder(): ?int
  93.     {
  94.         return $this->listOrder;
  95.     }
  96.     public function setListOrder(int $listOrder): self
  97.     {
  98.         $this->listOrder $listOrder;
  99.         return $this;
  100.     }
  101.     public function getActive(): ?int
  102.     {
  103.         return $this->active;
  104.     }
  105.     public function setActive(int $active): self
  106.     {
  107.         $this->active $active;
  108.         return $this;
  109.     }
  110.     public function getIdioma(): ?string
  111.     {
  112.         return $this->idioma;
  113.     }
  114.     public function setIdioma(?string $idioma): self
  115.     {
  116.         $this->idioma $idioma;
  117.         return $this;
  118.     }
  119.     /**
  120.      * @return Collection<int, Faq>
  121.      */
  122.     public function getFaqs(): Collection
  123.     {
  124.         return $this->faqs;
  125.     }
  126.     public function addFaq(Faq $faq): self
  127.     {
  128.         if (!$this->faqs->contains($faq)) {
  129.             $this->faqs->add($faq);
  130.             $faq->setCategory($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeFaq(Faq $faq): self
  135.     {
  136.         if ($this->faqs->removeElement($faq)) {
  137.             // set the owning side to null (unless already changed)
  138.             if ($faq->getCategory() === $this) {
  139.                 $faq->setCategory(null);
  140.             }
  141.         }
  142.         return $this;
  143.     }
  144.     public function isActive(): ?bool
  145.     {
  146.         return $this->active;
  147.     }
  148.     public function getSlug(): ?string
  149.     {
  150.         return $this->slug;
  151.     }
  152.     public function setSlug(?string $slug): self
  153.     {
  154.         $this->slug $slug;
  155.         return $this;
  156.     }
  157.    
  158. }