src/Entity/ChallengeStatus.php line 13
<?php
namespace App\Entity;
use App\Repository\ChallengeStatusRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: ChallengeStatusRepository::class)]
class ChallengeStatus
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Column(type: 'uuid', unique: true)]
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
private ?Uuid $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 191, unique: true)]
#[Gedmo\Slug(fields: ['name'])]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'status', targetEntity: Challenge::class)]
private Collection $challenges;
public function __construct()
{
$this->challenges = new ArrayCollection();
}
public function __toString() {
return $this->name;
}
public function getId(): ?Uuid
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Challenge>
*/
public function getChallenges(): Collection
{
return $this->challenges;
}
public function addChallenge(Challenge $challenge): self
{
if (!$this->challenges->contains($challenge)) {
$this->challenges->add($challenge);
$challenge->setStatus($this);
}
return $this;
}
public function removeChallenge(Challenge $challenge): self
{
if ($this->challenges->removeElement($challenge)) {
// set the owning side to null (unless already changed)
if ($challenge->getStatus() === $this) {
$challenge->setStatus(null);
}
}
return $this;
}
}