src/Entity/ChallengeStatus.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ChallengeStatusRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Uid\Uuid;
  9. #[ORM\Entity(repositoryClassChallengeStatusRepository::class)]
  10. class ChallengeStatus
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  14.     #[ORM\Column(type'uuid'uniquetrue)]
  15.     #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
  16.     private ?Uuid $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     
  20.     #[ORM\Column(length191uniquetrue)]
  21.     #[Gedmo\Slug(fields: ['name'])]
  22.     private ?string $slug null;
  23.     #[ORM\OneToMany(mappedBy'status'targetEntityChallenge::class)]
  24.     private Collection $challenges;
  25.     public function __construct()
  26.     {
  27.         $this->challenges = new ArrayCollection();
  28.     }
  29.     
  30.     public function __toString() {
  31.         return $this->name;
  32.     }
  33.     public function getId(): ?Uuid
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getName(): ?string
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function setName(string $name): self
  42.     {
  43.         $this->name $name;
  44.         return $this;
  45.     }
  46.     public function getSlug(): ?string
  47.     {
  48.         return $this->slug;
  49.     }
  50.     public function setSlug(string $slug): self
  51.     {
  52.         $this->slug $slug;
  53.         return $this;
  54.     }
  55.     /**
  56.      * @return Collection<int, Challenge>
  57.      */
  58.     public function getChallenges(): Collection
  59.     {
  60.         return $this->challenges;
  61.     }
  62.     public function addChallenge(Challenge $challenge): self
  63.     {
  64.         if (!$this->challenges->contains($challenge)) {
  65.             $this->challenges->add($challenge);
  66.             $challenge->setStatus($this);
  67.         }
  68.         return $this;
  69.     }
  70.     public function removeChallenge(Challenge $challenge): self
  71.     {
  72.         if ($this->challenges->removeElement($challenge)) {
  73.             // set the owning side to null (unless already changed)
  74.             if ($challenge->getStatus() === $this) {
  75.                 $challenge->setStatus(null);
  76.             }
  77.         }
  78.         return $this;
  79.     }
  80. }