src/Entity/CategoriesProjects.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\CreatedAtTrait;
  4. use App\Repository\CategoriesProjectsRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassCategoriesProjectsRepository::class)]
  9. class CategoriesProjects
  10. {
  11.     use CreatedAtTrait;
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $name null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $description null;
  20.     #[ORM\Column(length255)]
  21.     private ?string $slug null;
  22.             /*
  23.     #[ORM\Column]
  24.     private ?\DateTimeImmutable $createdAt = null;
  25.             */
  26.     #[ORM\OneToMany(mappedBy'categoriesprojects'targetEntityProjects::class)]
  27.     private Collection $projects;
  28.     public function __construct()
  29.     {
  30.         $this->projects = new ArrayCollection();
  31.         $this->created_at = new \DateTimeImmutable();
  32.         /// $this->createdAt = new \DateTimeImmutable(); /////////////////
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getName(): ?string
  39.     {
  40.         return $this->name;
  41.     }
  42.     public function setName(string $name): static
  43.     {
  44.         $this->name $name;
  45.         return $this;
  46.     }
  47.     public function getDescription(): ?string
  48.     {
  49.         return $this->description;
  50.     }
  51.     public function setDescription(string $description): static
  52.     {
  53.         $this->description $description;
  54.         return $this;
  55.     }
  56.     public function getSlug(): ?string
  57.     {
  58.         return $this->slug;
  59.     }
  60.     public function setSlug(string $slug): static
  61.     {
  62.         $this->slug $slug;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, Projects>
  67.      */
  68.     public function getProjects(): Collection
  69.     {
  70.         return $this->projects;
  71.     }
  72.     public function addProjects(Projects $project): static
  73.     {
  74.         if (!$this->projects->contains($project)) {
  75.             $this->projects->add($project);
  76.             $project->setCategoriesProjects($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeProject(Projects $project): static
  81.     {
  82.         if ($this->projects->removeElement($project)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($project->getCategoriesprojects() === $this) {
  85.                 $project->setCategoriesprojects(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90. }