src/Entity/Category.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\SubCategory;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\CategoryRepository;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. #[ORM\Entity(repositoryClassCategoryRepository::class)]
  9. class Category
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $name null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $slug null;
  19.     #[ORM\OneToMany(targetEntityPage::class, mappedBy'categories')]
  20.     private Collection $pages;
  21.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'subCategory')]
  22.     private ?self $mainCategory null;
  23.     #[ORM\OneToMany(mappedBy'mainCategory'targetEntitySubCategory::class)]
  24.     private Collection $subCategories;
  25.     public function __construct()
  26.     {
  27.         $this->pages = new ArrayCollection();
  28.         $this->subCategories = new ArrayCollection();
  29.     }
  30.     public function __toString()
  31.     {
  32.         return $this->name;
  33.     }
  34.     
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getName(): ?string
  40.     {
  41.         return $this->name;
  42.     }
  43.     public function setName(string $name): self
  44.     {
  45.         $this->name $name;
  46.         return $this;
  47.     }
  48.     /**
  49.      * @return Collection<int, Page>
  50.      */
  51.     public function getPages(): Collection
  52.     {
  53.         return $this->pages;
  54.     }
  55.  
  56.     public function getMainCategory(): ?self
  57.     {
  58.         return $this->mainCategory;
  59.     }
  60.     public function setMainCategory(?self $mainCategory): static
  61.     {
  62.         $this->mainCategory $mainCategory;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, SubCategory>
  67.      */
  68.     public function getSubCategories(): Collection
  69.     {
  70.         return $this->subCategories;
  71.     }
  72.     /**
  73.      * Get the value of slug
  74.      */ 
  75.     public function getSlug()
  76.     {
  77.         return $this->slug;
  78.     }
  79.     /**
  80.      * Set the value of slug
  81.      *
  82.      * @return  self
  83.      */ 
  84.     public function setSlug($slug)
  85.     {
  86.         $this->slug $slug;
  87.         return $this;
  88.     }
  89. }