src/Entity/Challenge.php line 16
<?php
namespace App\Entity;
use App\Repository\ChallengeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: ChallengeRepository::class)]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
class Challenge
{
use SoftDeleteableEntity;
#[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\Column(type: Types::TEXT)]
private ?string $short_description = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $full_description = null;
#[ORM\ManyToMany(targetEntity: ChallengeCategory::class, inversedBy: 'challenges')]
private Collection $categories;
#[ORM\ManyToOne(inversedBy: 'challenges')]
private ?ChallengeStatus $status = null;
#[ORM\ManyToMany(targetEntity: Course::class, inversedBy: 'challenges')]
private Collection $courses;
#[ORM\OneToMany(mappedBy: 'challenge', targetEntity: Milestone::class)]
private Collection $milestones;
#[ORM\OneToOne(cascade: ['persist'])]
#[ORM\JoinColumn(onDelete: 'CASCADE')]
#[ORM\ManyToOne(targetEntity: Image::class)]
private ?Image $image = null;
#[ORM\ManyToOne(inversedBy: 'challenges')]
private ?Partner $initiator = null;
#[ORM\ManyToMany(targetEntity: Partner::class, inversedBy: 'partner_challenges')]
private Collection $partners;
private ?string $publicUrl = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $active = null;
#[ORM\Column(type: 'date', nullable: true)]
private ?\DateTimeInterface $activeFrom = null;
#[ORM\Column(type: 'date', nullable: true)]
private ?\DateTimeInterface $activeTo = null;
public function __construct(
)
{
$this->categories = new ArrayCollection();
$this->courses = new ArrayCollection();
$this->milestones = new ArrayCollection();
$this->partners = 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;
}
/**
* @return string|null
*/
public function getSlug(): ?string
{
return $this->slug;
}
/**
* @param string|null $slug
*/
public function setSlug(?string $slug): void
{
$this->slug = $slug;
}
public function getShortDescription(): ?string
{
return $this->short_description;
}
public function setShortDescription(string $short_description): self
{
$this->short_description = $short_description;
return $this;
}
public function getFullDescription(): ?string
{
return $this->full_description;
}
public function setFullDescription(string $full_description): self
{
$this->full_description = $full_description;
return $this;
}
/**
* @return Collection<int, ChallengeCategory>
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(ChallengeCategory $category): self
{
if (!$this->categories->contains($category)) {
$this->categories->add($category);
}
return $this;
}
public function removeCategory(ChallengeCategory $category): self
{
$this->categories->removeElement($category);
return $this;
}
public function getStatus(): ?ChallengeStatus
{
return $this->status;
}
public function setStatus(?ChallengeStatus $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, Course>
*/
public function getCourses(): Collection
{
return $this->courses;
}
public function addCourse(Course $course): self
{
if (!$this->courses->contains($course)) {
$this->courses->add($course);
}
return $this;
}
public function removeCourse(Course $course): self
{
$this->courses->removeElement($course);
return $this;
}
/**
* @return Collection<int, Milestone>
*/
public function getMilestones(): Collection
{
return $this->milestones;
}
public function addMilestone(Milestone $milestone): self
{
if (!$this->milestones->contains($milestone)) {
$this->milestones->add($milestone);
$milestone->setChallenge($this);
}
return $this;
}
public function removeMilestone(Milestone $milestone): self
{
if ($this->milestones->removeElement($milestone)) {
// set the owning side to null (unless already changed)
if ($milestone->getChallenge() === $this) {
$milestone->setChallenge(null);
}
}
return $this;
}
public function getImage(): ?Image
{
return $this->image;
}
public function setImage(?Image $image): self
{
$this->image = $image;
return $this;
}
public function getInitiator(): ?Partner
{
return $this->initiator;
}
public function setInitiator(?Partner $initiator): self
{
$this->initiator = $initiator;
return $this;
}
/**
* @return Collection<int, Partner>
*/
public function getPartners(): Collection
{
return $this->partners;
}
public function addPartner(Partner $partner): self
{
if (!$this->partners->contains($partner)) {
$this->partners->add($partner);
}
return $this;
}
public function removePartner(Partner $partner): self
{
$this->partners->removeElement($partner);
return $this;
}
/**
* @return string|null
*/
public function getPublicUrl(): ?string
{
return $this->publicUrl;
}
/**
* @param string|null $publicUrl
*/
public function setPublicUrl(?string $publicUrl): void
{
$this->publicUrl = $publicUrl;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getActiveFrom(): ?\DateTimeInterface
{
return $this->activeFrom;
}
public function setActiveFrom(?\DateTimeInterface $activeFrom): self
{
$this->activeFrom = $activeFrom;
return $this;
}
public function getActiveTo(): ?\DateTimeInterface
{
return $this->activeTo;
}
public function setActiveTo(?\DateTimeInterface $activeTo): self
{
$this->activeTo = $activeTo;
return $this;
}
}