src/Entity/Challenge.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ChallengeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  10. use Symfony\Component\Uid\Uuid;
  11. #[ORM\Entity(repositoryClassChallengeRepository::class)]
  12. #[Gedmo\SoftDeleteable(fieldName'deletedAt'timeAwarefalsehardDeletetrue)]
  13. class Challenge
  14. {
  15.     use SoftDeleteableEntity;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  18.     #[ORM\Column(type'uuid'uniquetrue)]
  19.     #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
  20.     private ?Uuid $id null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $name null;
  23.     #[ORM\Column(length191uniquetrue)]
  24.     #[Gedmo\Slug(fields: ['name'])]
  25.     private ?string $slug null;
  26.     #[ORM\Column(typeTypes::TEXT)]
  27.     private ?string $short_description null;
  28.     #[ORM\Column(typeTypes::TEXT)]
  29.     private ?string $full_description null;
  30.     #[ORM\ManyToMany(targetEntityChallengeCategory::class, inversedBy'challenges')]
  31.     private Collection $categories;
  32.     #[ORM\ManyToOne(inversedBy'challenges')]
  33.     private ?ChallengeStatus $status null;
  34.     #[ORM\ManyToMany(targetEntityCourse::class, inversedBy'challenges')]
  35.     private Collection $courses;
  36.     #[ORM\OneToMany(mappedBy'challenge'targetEntityMilestone::class)]
  37.     private Collection $milestones;
  38.     #[ORM\OneToOne(cascade: ['persist'])]
  39.     #[ORM\JoinColumn(onDelete'CASCADE')]
  40.     #[ORM\ManyToOne(targetEntityImage::class)]
  41.     private ?Image $image null;
  42.     #[ORM\ManyToOne(inversedBy'challenges')]
  43.     private ?Partner $initiator null;
  44.     #[ORM\ManyToMany(targetEntityPartner::class, inversedBy'partner_challenges')]
  45.     private Collection $partners;
  46.     private ?string $publicUrl null;
  47.     #[ORM\Column(type'boolean'nullabletrue)]
  48.     private ?bool $active null;
  49.     #[ORM\Column(type'date'nullabletrue)]
  50.     private ?\DateTimeInterface $activeFrom null;
  51.     #[ORM\Column(type'date'nullabletrue)]
  52.     private ?\DateTimeInterface $activeTo null;
  53.     public function __construct(
  54.     )
  55.     {
  56.         $this->categories = new ArrayCollection();
  57.         $this->courses = new ArrayCollection();
  58.         $this->milestones = new ArrayCollection();
  59.         $this->partners = new ArrayCollection();
  60.     }
  61.     public function __toString() {
  62.         return $this->name;
  63.     }
  64.     public function getId(): ?Uuid
  65.     {
  66.         return $this->id;
  67.     }
  68.     public function getName(): ?string
  69.     {
  70.         return $this->name;
  71.     }
  72.     public function setName(string $name): self
  73.     {
  74.         $this->name $name;
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return string|null
  79.      */
  80.     public function getSlug(): ?string
  81.     {
  82.         return $this->slug;
  83.     }
  84.     /**
  85.      * @param string|null $slug
  86.      */
  87.     public function setSlug(?string $slug): void
  88.     {
  89.         $this->slug $slug;
  90.     }
  91.     public function getShortDescription(): ?string
  92.     {
  93.         return $this->short_description;
  94.     }
  95.     public function setShortDescription(string $short_description): self
  96.     {
  97.         $this->short_description $short_description;
  98.         return $this;
  99.     }
  100.     public function getFullDescription(): ?string
  101.     {
  102.         return $this->full_description;
  103.     }
  104.     public function setFullDescription(string $full_description): self
  105.     {
  106.         $this->full_description $full_description;
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return Collection<int, ChallengeCategory>
  111.      */
  112.     public function getCategories(): Collection
  113.     {
  114.         return $this->categories;
  115.     }
  116.     public function addCategory(ChallengeCategory $category): self
  117.     {
  118.         if (!$this->categories->contains($category)) {
  119.             $this->categories->add($category);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeCategory(ChallengeCategory $category): self
  124.     {
  125.         $this->categories->removeElement($category);
  126.         return $this;
  127.     }
  128.     public function getStatus(): ?ChallengeStatus
  129.     {
  130.         return $this->status;
  131.     }
  132.     public function setStatus(?ChallengeStatus $status): self
  133.     {
  134.         $this->status $status;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return Collection<int, Course>
  139.      */
  140.     public function getCourses(): Collection
  141.     {
  142.         return $this->courses;
  143.     }
  144.     public function addCourse(Course $course): self
  145.     {
  146.         if (!$this->courses->contains($course)) {
  147.             $this->courses->add($course);
  148.         }
  149.         return $this;
  150.     }
  151.     public function removeCourse(Course $course): self
  152.     {
  153.         $this->courses->removeElement($course);
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return Collection<int, Milestone>
  158.      */
  159.     public function getMilestones(): Collection
  160.     {
  161.         return $this->milestones;
  162.     }
  163.     public function addMilestone(Milestone $milestone): self
  164.     {
  165.         if (!$this->milestones->contains($milestone)) {
  166.             $this->milestones->add($milestone);
  167.             $milestone->setChallenge($this);
  168.         }
  169.         return $this;
  170.     }
  171.     public function removeMilestone(Milestone $milestone): self
  172.     {
  173.         if ($this->milestones->removeElement($milestone)) {
  174.             // set the owning side to null (unless already changed)
  175.             if ($milestone->getChallenge() === $this) {
  176.                 $milestone->setChallenge(null);
  177.             }
  178.         }
  179.         return $this;
  180.     }
  181.     public function getImage(): ?Image
  182.     {
  183.         return $this->image;
  184.     }
  185.     public function setImage(?Image $image): self
  186.     {
  187.         $this->image $image;
  188.         return $this;
  189.     }
  190.     public function getInitiator(): ?Partner
  191.     {
  192.         return $this->initiator;
  193.     }
  194.     public function setInitiator(?Partner $initiator): self
  195.     {
  196.         $this->initiator $initiator;
  197.         return $this;
  198.     }
  199.     /**
  200.      * @return Collection<int, Partner>
  201.      */
  202.     public function getPartners(): Collection
  203.     {
  204.         return $this->partners;
  205.     }
  206.     public function addPartner(Partner $partner): self
  207.     {
  208.         if (!$this->partners->contains($partner)) {
  209.             $this->partners->add($partner);
  210.         }
  211.         return $this;
  212.     }
  213.     public function removePartner(Partner $partner): self
  214.     {
  215.         $this->partners->removeElement($partner);
  216.         return $this;
  217.     }
  218.     /**
  219.      * @return string|null
  220.      */
  221.     public function getPublicUrl(): ?string
  222.     {
  223.         return $this->publicUrl;
  224.     }
  225.     /**
  226.      * @param string|null $publicUrl
  227.      */
  228.     public function setPublicUrl(?string $publicUrl): void
  229.     {
  230.         $this->publicUrl $publicUrl;
  231.     }
  232.     public function isActive(): ?bool
  233.     {
  234.         return $this->active;
  235.     }
  236.     public function setActive(bool $active): self
  237.     {
  238.         $this->active $active;
  239.         return $this;
  240.     }
  241.     public function getActiveFrom(): ?\DateTimeInterface
  242.     {
  243.         return $this->activeFrom;
  244.     }
  245.     public function setActiveFrom(?\DateTimeInterface $activeFrom): self
  246.     {
  247.         $this->activeFrom $activeFrom;
  248.         return $this;
  249.     }
  250.     public function getActiveTo(): ?\DateTimeInterface
  251.     {
  252.         return $this->activeTo;
  253.     }
  254.     public function setActiveTo(?\DateTimeInterface $activeTo): self
  255.     {
  256.         $this->activeTo $activeTo;
  257.         return $this;
  258.     }
  259. }