src/Entity/Categorie.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping\Entity;
  6. use Doctrine\ORM\Mapping\Table;
  7. use Doctrine\ORM\Mapping\Id;
  8. use Doctrine\ORM\Mapping\GeneratedValue;
  9. use Doctrine\ORM\Mapping\Column;
  10. use Doctrine\ORM\Mapping\OneToMany;
  11. #[Entity]
  12. #[Table(name"categorie")]
  13. class Categorie
  14. {
  15.     #[Id]
  16.     #[GeneratedValue]
  17.     #[Column(type"integer")]
  18.     private int $id;
  19.     #[Column(type"string"length255)]
  20.     private string $nom;
  21.     #[OneToMany(mappedBy"categorie"targetEntityPrestation::class)]
  22.     private Collection $prestations;
  23.     #[Column(type"boolean")]
  24.     private bool $deleted false;
  25.     public function __construct()
  26.     {
  27.         $this->prestations = new ArrayCollection();
  28.     }
  29.     public function getId(): int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function setId(int $id): void
  34.     {
  35.         $this->id $id;
  36.     }
  37.     public function getNom(): string
  38.     {
  39.         return $this->nom;
  40.     }
  41.     public function setNom(string $nom): void
  42.     {
  43.         $this->nom $nom;
  44.     }
  45.     /**
  46.      * @return Collection<int, Prestation>
  47.      */
  48.     public function getPrestations(): Collection
  49.     {
  50.         return $this->prestations;
  51.     }
  52.     public function addPrestation(Prestation $prestation): self
  53.     {
  54.         if (!$this->prestations->contains($prestation)) {
  55.             $this->prestations[] = $prestation;
  56.             $prestation->setCategorie($this);
  57.         }
  58.         return $this;
  59.     }
  60.     public function removePrestation(Prestation $prestation): self
  61.     {
  62.         if ($this->prestations->removeElement($prestation)) {
  63.             // set the owning side to null (unless already changed)
  64.             if ($prestation->getCategorie() === $this) {
  65.                 $prestation->setCategorie(null);
  66.             }
  67.         }
  68.         return $this;
  69.     }
  70.     public function setPrestations(Collection $prestations): self
  71.     {
  72.         $this->prestations $prestations;
  73.         return $this;
  74.     }
  75.     public function isDeleted(): bool
  76.     {
  77.         return $this->deleted;
  78.     }
  79.     public function setDeleted(bool $deleted): void
  80.     {
  81.         $this->deleted $deleted;
  82.     }
  83.     /**
  84.      * @return Collection<int, Prestation>
  85.      */
  86.     public function getActivePrestations(): Collection
  87.     {
  88.         return $this->prestations->filter(function(Prestation $prestation) {
  89.             return !$prestation->isDeleted();
  90.         });
  91.     }
  92.     /**
  93.      * @return Collection<int, Prestation>
  94.      */
  95.     public function getAllPrestations(): Collection
  96.     {
  97.         return $this->prestations;
  98.     }
  99. }