src/Entity/Categories.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\CreatedAtTrait;
  4. use App\Entity\Trait\SlugTrait;
  5. use App\Repository\CategoriesRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassCategoriesRepository::class)]
  10. class Categories
  11. {
  12.     use CreatedAtTrait;
  13.     use SlugTrait;
  14.     
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length100)]
  20.     private ?string $name null;
  21.     #[ORM\Column(type'integer')]
  22.     private $categoryOrder;
  23.     // #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'categories')]
  24.     // #[ORM\JoinColumn(onDelete: 'CASCADE')]
  25.     // private ?self $parent = null;
  26.     // #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
  27.     // private Collection $categories;
  28.     #[ORM\OneToMany(mappedBy'categories'targetEntityProducts::class)]
  29.     private Collection $products;
  30.     #[ORM\Column(length255)]
  31.     private ?string $description null;
  32.     /**** #[ORM\Column(nullable: true)]
  33.     private ?\DateTimeImmutable $createdAt = null;   ***/
  34.     public function __construct()
  35.     {
  36.         // $this->categories = new ArrayCollection();
  37.         $this->products = new ArrayCollection();
  38.         $this->created_at = new \DateTimeImmutable();
  39.         //// $this->createdAt = new \DateTimeImmutable();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(string $name): static
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54.     public function getCategoryOrder(): ?int 
  55.     {
  56.         return $this->categoryOrder
  57.     }
  58.     public function setCategoryOrder(int $categoryOrder): self
  59.     {
  60.         $this->categoryOrder $categoryOrder;
  61.         return $this;
  62.     }
  63.         /*****
  64.     public function getParent(): ?self
  65.     {
  66.         return $this->parent;
  67.     }    
  68.     public function setParent(?self $parent): static
  69.     {
  70.         $this->parent = $parent;
  71.         return $this;
  72.     }            ****/
  73.             /*
  74.     /**
  75.      * @return Collection<int, self>
  76.      */
  77.     /******** 
  78.     public function getCategories(): Collection
  79.     {
  80.         return $this->categories;
  81.     }
  82.     public function addCategory(self $category): static
  83.     {
  84.         if (!$this->categories->contains($category)) {
  85.             $this->categories->add($category);
  86.             $category->setParent($this);
  87.         }
  88.         return $this;
  89.     }   
  90.     public function removeCategory(self $category): static
  91.     {
  92.         if ($this->categories->removeElement($category)) {
  93.             // set the owning side to null (unless already changed)
  94.             if ($category->getParent() === $this) {
  95.                 $category->setParent(null);
  96.             }
  97.         }
  98.         return $this;
  99.     }   *******/
  100.     /**
  101.      * @return Collection<int, Products>
  102.      */
  103.     public function getProducts(): Collection
  104.     {
  105.         return $this->products;
  106.     }
  107.     public function addProduct(Products $product): static
  108.     {
  109.         if (!$this->products->contains($product)) {
  110.             $this->products->add($product);
  111.             $product->setCategories($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeProduct(Products $product): static
  116.     {
  117.         if ($this->products->removeElement($product)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($product->getCategories() === $this) {
  120.                 $product->setCategories(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125.     public function getDescription(): ?string
  126.     {
  127.         return $this->description;
  128.     }
  129.     public function setDescription(string $description): static
  130.     {
  131.         $this->description $description;
  132.         return $this;
  133.     }
  134.             /***** 
  135.     public function getCreatedAt(): ?\DateTimeImmutable
  136.     {
  137.         return $this->createdAt;
  138.     }
  139.     public function setCreatedAt(?\DateTimeImmutable $createdAt): static
  140.     {
  141.         $this->createdAt = $createdAt;
  142.         return $this;
  143.     }            
  144.             *****/
  145. }