src/Entity/Secteur.php line 10

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity()]
  7. class Secteur
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column(type'integer')]
  12.     private $id;
  13.     #[ORM\Column(type'string'length255)]
  14.     private $nom;
  15.     #[ORM\ManyToOne(targetEntityUser::class)]
  16.     #[ORM\JoinColumn(nullabletrue)]
  17.     private $user;
  18.     #[ORM\Column(type'date'nullabletrue)]
  19.     private $creation;
  20.     #[ORM\Column(type'datetime'nullabletrue)]
  21.     private $modification;
  22.     #[ORM\OneToMany(mappedBy'secteur'targetEntityMetier::class)]
  23.     private $metiers;
  24.     public function __construct()
  25.     {
  26.         $this->metiers = new ArrayCollection();
  27.     }
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getNom(): ?string
  33.     {
  34.         return $this->nom;
  35.     }
  36.     public function setNom(?string $nom): self
  37.     {
  38.         $this->nom $nom;
  39.         return $this;
  40.     }
  41.     public function getUser(): ?User
  42.     {
  43.         return $this->user;
  44.     }
  45.     public function setUser(?User $user): self
  46.     {
  47.         $this->user $user;
  48.         return $this;
  49.     }
  50.     public function getCreation(): ?\DateTimeInterface
  51.     {
  52.         return $this->creation;
  53.     }
  54.     public function setCreation(?\DateTimeInterface $creation): self
  55.     {
  56.         $this->creation $creation;
  57.         return $this;
  58.     }
  59.     public function getModification(): ?\DateTimeInterface
  60.     {
  61.         return $this->modification;
  62.     }
  63.     public function setModification(?\DateTimeInterface $modification): self
  64.     {
  65.         $this->modification $modification;
  66.         return $this;
  67.     }
  68.     /**
  69.      * @return Collection<int, Metier>
  70.      */
  71.     public function getMetiers(): Collection
  72.     {
  73.         return $this->metiers;
  74.     }
  75.     public function addMetier(Metier $metier): self
  76.     {
  77.         if (!$this->metiers->contains($metier)) {
  78.             $this->metiers[] = $metier;
  79.             $metier->setSecteur($this);
  80.         }
  81.         return $this;
  82.     }
  83.     public function removeMetier(Metier $metier): self
  84.     {
  85.         if ($this->metiers->removeElement($metier)) {
  86.             if ($metier->getSecteur() === $this) {
  87.                 $metier->setSecteur(null);
  88.             }
  89.         }
  90.         return $this;
  91.     }
  92. }