src/Entity/Category.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Anotation as Gedmo;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Entity(repositoryClassCategoryRepository::class)]
  10. class Category
  11. {
  12.     use TimestampableEntity;
  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]
  20.     private ?bool $statut null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $slug null;
  23.     #[Gedmo\Timestampable(on :'create')]
  24.     private ?\DateTimeImmutable $created_at null;
  25.     
  26.     #[Gedmo\Timestampable(on :'update')]
  27.     private ?\DateTimeImmutable $updated_at null;
  28.     #[ORM\OneToMany(mappedBy'category'targetEntityActuallite::class)]
  29.     private Collection $actuallites;
  30.     public function __construct()
  31.     {
  32.         $this->actuallites = new ArrayCollection();
  33.     }
  34.     public function __toString(){
  35.         return $this->getName();
  36.     }
  37.     public function getId(): ?int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getName(): ?string
  42.     {
  43.         return $this->name;
  44.     }
  45.     public function setName(string $name): self
  46.     {
  47.         $this->name $name;
  48.         return $this;
  49.     }
  50.     public function isStatut(): ?bool
  51.     {
  52.         return $this->statut;
  53.     }
  54.     public function setStatut(bool $statut): self
  55.     {
  56.         $this->statut $statut;
  57.         return $this;
  58.     }
  59.     public function getSlug(): ?string
  60.     {
  61.         return $this->slug;
  62.     }
  63.     public function setSlug(string $slug): self
  64.     {
  65.         $this->slug $slug;
  66.         return $this;
  67.     }
  68.     public function getCreatedAt(): ?\DateTimeImmutable
  69.     {
  70.         return $this->created_at;
  71.     }
  72.     public function getUpdatedAt(): ?\DateTimeImmutable
  73.     {
  74.         return $this->updated_at;
  75.     }
  76.     /**
  77.      * @return Collection<int, Actuallite>
  78.      */
  79.     public function getActuallites(): Collection
  80.     {
  81.         return $this->actuallites;
  82.     }
  83.     public function addActuallite(Actuallite $actuallite): self
  84.     {
  85.         if (!$this->actuallites->contains($actuallite)) {
  86.             $this->actuallites->add($actuallite);
  87.             $actuallite->setCategory($this);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeActuallite(Actuallite $actuallite): self
  92.     {
  93.         if ($this->actuallites->removeElement($actuallite)) {
  94.             // set the owning side to null (unless already changed)
  95.             if ($actuallite->getCategory() === $this) {
  96.                 $actuallite->setCategory(null);
  97.             }
  98.         }
  99.         return $this;
  100.     }
  101. }