<?phpnamespace App\Entity;use App\Entity\Traits\TimeStampable;use App\Repository\CategorieProjetRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints as Assert;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;#[ORM\Entity(repositoryClass: CategorieProjetRepository::class)]#[UniqueEntity( fields: ['title',], errorPath: 'title', message: 'Le nom que vous avez saisi est déjà utilisé',)]#[ORM\HasLifecycleCallbacks]class CategorieProjet{ use TimeStampable; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(["entity:write"])] private ?int $id = null; #[ORM\Column(length: 255)] #[Groups(["entity:write"])] #[Assert\NotBlank(message:"Veuillez remplir ce champ")] private ?string $title = null; #[ORM\Column(type: Types::TEXT, nullable: true)] #[Groups(["entity:write"])] private ?string $description = null; #[ORM\OneToMany(mappedBy: 'categorieProjet', targetEntity: Projet::class)] private Collection $projets; #[ORM\ManyToOne(inversedBy: 'categorieProjets')] private ?User $createdBy = null; public function __construct() { $this->projets = new ArrayCollection(); $this->isEnabled = false; $this->createdAt = new \DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getTitle(): ?string { return $this->title; } public function setTitle(string $title): self { $this->title = $title; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(string $description): self { $this->description = $description; return $this; } /** * @return Collection<int, Projet> */ public function getProjets(): Collection { return $this->projets; } public function addProjet(Projet $projet): self { if (!$this->projets->contains($projet)) { $this->projets->add($projet); $projet->setCategorieProjet($this); } return $this; } public function removeProjet(Projet $projet): self { if ($this->projets->removeElement($projet)) { // set the owning side to null (unless already changed) if ($projet->getCategorieProjet() === $this) { $projet->setCategorieProjet(null); } } return $this; } public function getCreatedBy(): ?User { return $this->createdBy; } public function setCreatedBy(?User $createdBy): static { $this->createdBy = $createdBy; return $this; } public function __toString() { return $this->title; }}