src/Entity/Departement.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DepartementRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassDepartementRepository::class)]
  8. class Departement
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length100)]
  15.     private ?string $nom null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $description null;
  18.     #[ORM\Column]
  19.     private ?\DateTimeImmutable $createdAt null;
  20.     #[ORM\OneToMany(mappedBy'departement'targetEntityEmploye::class)]
  21.     private Collection $employes;
  22.     #[ORM\Column]
  23.     private ?bool $estActif true;
  24.     #[ORM\ManyToOne(targetEntityEmploye::class)]
  25.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  26.     private ?Employe $responsable null;
  27.     public function __construct()
  28.     {
  29.         $this->employes = new ArrayCollection();
  30.         $this->createdAt = new \DateTimeImmutable();
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getNom(): ?string
  37.     {
  38.         return $this->nom;
  39.     }
  40.     public function setNom(string $nom): static
  41.     {
  42.         $this->nom $nom;
  43.         return $this;
  44.     }
  45.     public function getDescription(): ?string
  46.     {
  47.         return $this->description;
  48.     }
  49.     public function setDescription(?string $description): static
  50.     {
  51.         $this->description $description;
  52.         return $this;
  53.     }
  54.     public function getCreatedAt(): ?\DateTimeImmutable
  55.     {
  56.         return $this->createdAt;
  57.     }
  58.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  59.     {
  60.         $this->createdAt $createdAt;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return Collection<int, Employe>
  65.      */
  66.     public function getEmployes(): Collection
  67.     {
  68.         return $this->employes;
  69.     }
  70.     public function addEmploye(Employe $employe): static
  71.     {
  72.         if (!$this->employes->contains($employe)) {
  73.             $this->employes->add($employe);
  74.             $employe->setDepartement($this);
  75.         }
  76.         return $this;
  77.     }
  78.     public function removeEmploye(Employe $employe): static
  79.     {
  80.         if ($this->employes->removeElement($employe)) {
  81.             if ($employe->getDepartement() === $this) {
  82.                 $employe->setDepartement(null);
  83.             }
  84.         }
  85.         return $this;
  86.     }
  87.     public function isEstActif(): ?bool
  88.     {
  89.         return $this->estActif;
  90.     }
  91.     public function setEstActif(bool $estActif): static
  92.     {
  93.         $this->estActif $estActif;
  94.         return $this;
  95.     }
  96.     public function getResponsable(): ?Employe
  97.     {
  98.         return $this->responsable;
  99.     }
  100.     public function setResponsable(?Employe $responsable): static
  101.     {
  102.         $this->responsable $responsable;
  103.         return $this;
  104.     }
  105.     public function __toString(): string
  106.     {
  107.         return $this->nom ?? '';
  108.     }
  109. }