<?phpnamespace App\Entity;use App\Entity\Traits\TimeStampable;use App\Repository\StructureTypeRepository;use Doctrine\ORM\Mapping as ORM;use Doctrine\DBAL\Types\Types;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: StructureTypeRepository::class)]#[UniqueEntity( fields: ['name',], errorPath: 'name', message: 'Le nom que vous avez saisi est déjà utilisé',)]#[ORM\HasLifecycleCallbacks]class StructureType{ use TimeStampable; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] #[Groups(["entity:write"])] private ?int $id = null; #[ORM\Column(length: 46)] #[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\OneToMany(mappedBy: 'structureType', targetEntity: Structure::class)] private Collection $structures; public function __construct() { $this->createdAt = new \DateTimeImmutable(); $this->updatedAt = new \DateTimeImmutable(); $this->structures = 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 getCreatedBy(): ?User { return $this->createdBy; } public function setCreatedBy(?User $createdBy): self { $this->createdBy = $createdBy; return $this; } /** * @return Collection<int, Structure> */ public function getStructures(): Collection { return $this->structures; } public function addProjetBailleur(Structure $structure): self { if (!$this->structures->contains($structure)) { $this->structures->add($structure); $structure->setStructureType($this); } return $this; } public function removeProjetBailleur(Structure $structure): self { if ($this->structures->removeElement($structure)) { // set the owning side to null (unless already changed) if ($structure->getStructureType() === $this) { $structure->setStructureType(null); } } return $this; } public function __toString(){ return $this->name; }}