<?phpnamespace App\Entity;use App\Repository\DepartementRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: DepartementRepository::class)]class Departement{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 100)] private ?string $nom = null; #[ORM\Column(length: 255, nullable: true)] private ?string $description = null; #[ORM\Column] private ?\DateTimeImmutable $createdAt = null; #[ORM\OneToMany(mappedBy: 'departement', targetEntity: Employe::class)] private Collection $employes; #[ORM\Column] private ?bool $estActif = true; #[ORM\ManyToOne(targetEntity: Employe::class)] #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] private ?Employe $responsable = null; public function __construct() { $this->employes = new ArrayCollection(); $this->createdAt = new \DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getNom(): ?string { return $this->nom; } public function setNom(string $nom): static { $this->nom = $nom; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): static { $this->description = $description; return $this; } public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; } public function setCreatedAt(\DateTimeImmutable $createdAt): static { $this->createdAt = $createdAt; return $this; } /** * @return Collection<int, Employe> */ public function getEmployes(): Collection { return $this->employes; } public function addEmploye(Employe $employe): static { if (!$this->employes->contains($employe)) { $this->employes->add($employe); $employe->setDepartement($this); } return $this; } public function removeEmploye(Employe $employe): static { if ($this->employes->removeElement($employe)) { if ($employe->getDepartement() === $this) { $employe->setDepartement(null); } } return $this; } public function isEstActif(): ?bool { return $this->estActif; } public function setEstActif(bool $estActif): static { $this->estActif = $estActif; return $this; } public function getResponsable(): ?Employe { return $this->responsable; } public function setResponsable(?Employe $responsable): static { $this->responsable = $responsable; return $this; } public function __toString(): string { return $this->nom ?? ''; }}