<?php
namespace App\Entity;
use App\Entity\Trait\CreatedAtTrait;
use App\Repository\CategoriesProjectsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoriesProjectsRepository::class)]
class CategoriesProjects
{
use CreatedAtTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255)]
private ?string $description = null;
#[ORM\Column(length: 255)]
private ?string $slug = null;
/*
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
*/
#[ORM\OneToMany(mappedBy: 'categoriesprojects', targetEntity: Projects::class)]
private Collection $projects;
public function __construct()
{
$this->projects = new ArrayCollection();
$this->created_at = new \DateTimeImmutable();
/// $this->createdAt = new \DateTimeImmutable(); /////////////////
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): static
{
$this->description = $description;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): static
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Projects>
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProjects(Projects $project): static
{
if (!$this->projects->contains($project)) {
$this->projects->add($project);
$project->setCategoriesProjects($this);
}
return $this;
}
public function removeProject(Projects $project): static
{
if ($this->projects->removeElement($project)) {
// set the owning side to null (unless already changed)
if ($project->getCategoriesprojects() === $this) {
$project->setCategoriesprojects(null);
}
}
return $this;
}
}