src/Entity/Categorie.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestamp;
  4. use App\Repository\CategorieRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassCategorieRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. class Categorie
  11. {
  12.     use Timestamp;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(length255)]
  20.     private ?string $slug null;
  21.     #[ORM\OneToMany(mappedBy'categorie'targetEntityProjet::class)]
  22.     private Collection $projets;
  23.     public function __construct()
  24.     {
  25.         $this->projets = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getName(): ?string
  32.     {
  33.         return $this->name;
  34.     }
  35.     public function setName(string $name): static
  36.     {
  37.         $this->name $name;
  38.         return $this;
  39.     }
  40.     public function getSlug(): ?string
  41.     {
  42.         return $this->slug;
  43.     }
  44.     public function setSlug(string $slug): static
  45.     {
  46.         $this->slug $slug;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, Projet>
  51.      */
  52.     public function getProjets(): Collection
  53.     {
  54.         return $this->projets;
  55.     }
  56.     public function addProjet(Projet $projet): self
  57.     {
  58.         if (!$this->projets->contains($projet)) {
  59.             $this->projets->add($projet);
  60.             $projet->setCategorie($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeProjet(Projet $projet): self
  65.     {
  66.         if ($this->projets->removeElement($projet)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($projet->getCategorie() === $this) {
  69.                 $projet->setCategorie(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74.     public function __toString()
  75.     {
  76.         return $this->getName();
  77.     }
  78. }