src/Entity/ShopCategory.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ShopCategoryRepository;
  4. use DateTimeImmutable;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassShopCategoryRepository::class)]
  12. class ShopCategory
  13. {
  14.     
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\OneToMany(targetEntityShop::class, mappedBy'shopCategory')]
  20.     private Collection $shops;
  21.     #[ORM\Column(length100)]
  22.     #[Assert\NotBlank]
  23.     #[Assert\Length(min2max100)]
  24.     private ?string $name null;
  25.     #[ORM\Column(length120uniquetrue)]
  26.     private ?string $slug null;
  27.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  28.     #[Assert\Length(max1000)]
  29.     private ?string $description null;
  30.     #[ORM\Column(length255nullabletrue)]
  31.     private ?string $bannerImage null;
  32.     #[ORM\Column]
  33.     private ?int $position 0;
  34.     #[ORM\Column]
  35.     private ?bool $isActive true;
  36.     #[ORM\Column]
  37.     private ?DateTimeImmutable $createdAt null;
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?DateTimeImmutable $updatedAt null;
  40.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'children')]
  41.     private ?self $parent null;
  42.     #[ORM\OneToMany(targetEntityself::class, mappedBy'parent')]
  43.     private Collection $children;
  44.     public function __construct()
  45.     {
  46.         $this->shops = new ArrayCollection();
  47.         $this->children = new ArrayCollection();
  48.     }
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     /**
  54.      * @return Collection<int, Shop>
  55.      */
  56.     public function getShops(): Collection
  57.     {
  58.         return $this->shops;
  59.     }
  60.     public function addShop(Shop $shop): static
  61.     {
  62.         if (!$this->shops->contains($shop)) {
  63.             $this->shops->add($shop);
  64.             $shop->setShopCategory($this);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeShop(Shop $shop): static
  69.     {
  70.         if ($this->shops->removeElement($shop)) {
  71.             // set the owning side to null (unless already changed)
  72.             if ($shop->getShopCategory() === $this) {
  73.                 $shop->setShopCategory(null);
  74.             }
  75.         }
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return string|null
  80.      */
  81.     public function getName(): ?string
  82.     {
  83.         return $this->name;
  84.     }
  85.     /**
  86.      * @param string|null $name
  87.      * @return ShopCategory
  88.      */
  89.     public function setName(?string $name): ShopCategory
  90.     {
  91.         $this->name $name;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @return string|null
  96.      */
  97.     public function getSlug(): ?string
  98.     {
  99.         return $this->slug;
  100.     }
  101.     /**
  102.      * @param string|null $slug
  103.      * @return ShopCategory
  104.      */
  105.     public function setSlug(?string $slug): ShopCategory
  106.     {
  107.         $this->slug $slug;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @return string|null
  112.      */
  113.     public function getDescription(): ?string
  114.     {
  115.         return $this->description;
  116.     }
  117.     /**
  118.      * @param string|null $description
  119.      * @return ShopCategory
  120.      */
  121.     public function setDescription(?string $description): ShopCategory
  122.     {
  123.         $this->description $description;
  124.         return $this;
  125.     }
  126.     /**
  127.      * @return string|null
  128.      */
  129.     public function getBannerImage(): ?string
  130.     {
  131.         return $this->bannerImage;
  132.     }
  133.     /**
  134.      * @param string|null $bannerImage
  135.      * @return ShopCategory
  136.      */
  137.     public function setBannerImage(?string $bannerImage): ShopCategory
  138.     {
  139.         $this->bannerImage $bannerImage;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return int|null
  144.      */
  145.     public function getPosition(): ?int
  146.     {
  147.         return $this->position;
  148.     }
  149.     /**
  150.      * @param int|null $position
  151.      * @return ShopCategory
  152.      */
  153.     public function setPosition(?int $position): ShopCategory
  154.     {
  155.         $this->position $position;
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return bool|null
  160.      */
  161.     public function getIsActive(): ?bool
  162.     {
  163.         return $this->isActive;
  164.     }
  165.     /**
  166.      * @param bool|null $isActive
  167.      * @return ShopCategory
  168.      */
  169.     public function setIsActive(?bool $isActive): ShopCategory
  170.     {
  171.         $this->isActive $isActive;
  172.         return $this;
  173.     }
  174.     /**
  175.      * @return DateTimeImmutable|null
  176.      */
  177.     public function getCreatedAt(): ?DateTimeImmutable
  178.     {
  179.         return $this->createdAt;
  180.     }
  181.     /**
  182.      * @param DateTimeImmutable|null $createdAt
  183.      * @return ShopCategory
  184.      */
  185.     public function setCreatedAt(?DateTimeImmutable $createdAt): ShopCategory
  186.     {
  187.         $this->createdAt $createdAt;
  188.         return $this;
  189.     }
  190.     /**
  191.      * @return DateTimeImmutable|null
  192.      */
  193.     public function getUpdatedAt(): ?DateTimeImmutable
  194.     {
  195.         return $this->updatedAt;
  196.     }
  197.     /**
  198.      * @param DateTimeImmutable|null $updatedAt
  199.      * @return ShopCategory
  200.      */
  201.     public function setUpdatedAt(?DateTimeImmutable $updatedAt): ShopCategory
  202.     {
  203.         $this->updatedAt $updatedAt;
  204.         return $this;
  205.     }
  206.     /**
  207.      * @return ShopCategory|null
  208.      */
  209.     public function getParent(): ?ShopCategory
  210.     {
  211.         return $this->parent;
  212.     }
  213.     /**
  214.      * @param ShopCategory|null $parent
  215.      * @return ShopCategory
  216.      */
  217.     public function setParent(?ShopCategory $parent): ShopCategory
  218.     {
  219.         $this->parent $parent;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection
  224.      */
  225.     public function getChildren(): Collection
  226.     {
  227.         return $this->children;
  228.     }
  229.     /**
  230.      * @param Collection $children
  231.      * @return ShopCategory
  232.      */
  233.     public function setChildren(Collection $children): ShopCategory
  234.     {
  235.         $this->children $children;
  236.         return $this;
  237.     }
  238.     public function __toString(): string
  239.     {
  240.         return $this->name ?? '';
  241.     }
  242. }