<?phpnamespace App\Entity;use App\Entity\Traits\TimeStampable;use App\Repository\MeetingCategoryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints as Assert;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: MeetingCategoryRepository::class)]#[UniqueEntity( fields: ['name',], errorPath: 'name', message: 'Le nom que vous avez saisi est déjà utilisé',)]#[ORM\HasLifecycleCallbacks]class MeetingCategory{ use TimeStampable; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(["entity:write"])] private ?int $id = null; #[ORM\Column(length: 65)] #[Groups(["entity:write"])] #[Assert\NotBlank(message:"Veuillez remplir ce champ")] private ?string $name = null; #[ORM\Column(type: Types::TEXT, nullable: true)] #[Groups(["entity:write"])] private ?string $description = null; #[ORM\ManyToOne] private ?User $createdBy = null; #[ORM\Column(length: 16, nullable: true)] #[Groups(["entity:write"])] private ?string $code = null; #[ORM\OneToMany(mappedBy: 'meetingCategories', targetEntity: Meeting::class)] private Collection $meetings; public function __construct() { $this->createdAt = new \DateTimeImmutable(); $this->updatedAt = new \DateTimeImmutable(); $this->meetings = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function setCreatedBy(?User $createdBy): self { $this->createdBy = $createdBy; return $this; } public function __toString(): string { return $this->name; } public function getCode(): ?string { return $this->code; } public function setCode(?string $code): self { $this->code = $code; return $this; } /** * @return Collection<int, Meeting> */ public function getMeetings(): Collection { return $this->meetings; } public function addMeeting(Meeting $meeting): self { if (!$this->meetings->contains($meeting)) { $this->meetings->add($meeting); $meeting->setMeetingCategories($this); } return $this; } public function removeMeeting(Meeting $meeting): self { if ($this->meetings->removeElement($meeting)) { // set the owning side to null (unless already changed) if ($meeting->getMeetingCategories() === $this) { $meeting->setMeetingCategories(null); } } return $this; }}