*/ #[ORM\ManyToMany(targetEntity: Machine::class, mappedBy: 'constructeurs')] private Collection $machines; /** * @var Collection */ #[ORM\ManyToMany(targetEntity: Composant::class, mappedBy: 'constructeurs')] private Collection $composants; /** * @var Collection */ #[ORM\ManyToMany(targetEntity: Piece::class, mappedBy: 'constructeurs')] private Collection $pieces; /** * @var Collection */ #[ORM\ManyToMany(targetEntity: Product::class, mappedBy: 'constructeurs')] private Collection $products; public function __construct() { $this->machines = new ArrayCollection(); $this->composants = new ArrayCollection(); $this->pieces = new ArrayCollection(); $this->products = new ArrayCollection(); } #[ORM\PrePersist] public function setCreatedAtValue(): void { $now = new \DateTimeImmutable(); $this->createdAt = $now; $this->updatedAt = $now; if ($this->id === null) { $this->id = $this->generateCuid(); } } #[ORM\PreUpdate] public function setUpdatedAtValue(): void { $this->updatedAt = new \DateTimeImmutable(); } private function generateCuid(): string { return 'cl' . bin2hex(random_bytes(12)); } public function getId(): ?string { return $this->id; } public function setId(string $id): static { $this->id = $id; return $this; } public function getName(): string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getEmail(): ?string { return $this->email; } public function setEmail(?string $email): static { $this->email = $email; return $this; } public function getPhone(): ?string { return $this->phone; } public function setPhone(?string $phone): static { $this->phone = $phone; return $this; } public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } public function getUpdatedAt(): \DateTimeImmutable { return $this->updatedAt; } }