src/Entity/SubCategory.php line 12

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