src/Entity/Season.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SeasonRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassSeasonRepository::class)]
  8. class Season
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\Column(type'string'length50nullabletrue)]
  15.     private $name;
  16.     #[ORM\Column(type'date_immutable')]
  17.     private $startAt;
  18.     #[ORM\Column(type'date_immutable')]
  19.     private $endAt;
  20.     #[ORM\Column(type'boolean')]
  21.     private $isActive;
  22.     #[ORM\ManyToOne(targetEntityGlobalSeason::class, inversedBy'seasons')]
  23.     #[ORM\JoinColumn(nullablefalse)]
  24.     private $globalSeason;
  25.     #[ORM\OneToOne(inversedBy'nextSeason'targetEntityself::class, cascade: ['persist'])]
  26.     private $previousSeason;
  27.     #[ORM\OneToOne(mappedBy'previousSeason'targetEntityself::class, cascade: ['persist'])]
  28.     private $nextSeason;
  29.     #[ORM\ManyToOne(targetEntitySection::class, inversedBy'seasons')]
  30.     #[ORM\JoinColumn(nullablefalse)]
  31.     private $section;
  32.     #[ORM\OneToMany(mappedBy'season'targetEntityCoach::class)]
  33.     private $coaches;
  34.     #[ORM\OneToMany(mappedBy'season'targetEntityLesson::class)]
  35.     private $lessons;
  36.     #[ORM\OneToMany(mappedBy'season'targetEntityDocumentModel::class)]
  37.     private $documentModels;
  38.     #[ORM\OneToMany(mappedBy'season'targetEntityRegistration::class)]
  39.     private $registrations;
  40.     #[ORM\OneToMany(mappedBy'season'targetEntityProfiling::class)]
  41.     private $profilings;
  42.     #[ORM\OneToMany(mappedBy'season'targetEntityProfilingPerson::class)]
  43.     private $profilingPersons;
  44.     #[ORM\OneToMany(mappedBy'season'targetEntityEnvelope::class)]
  45.     private $envelopes;
  46.     #[ORM\OneToMany(mappedBy'season'targetEntitySlot::class)]
  47.     private $slots;
  48.     #[ORM\Column(type'boolean')]
  49.     private $migrated false;
  50.     public function __construct()
  51.     {
  52.         $this->coaches = new ArrayCollection();
  53.         $this->lessons = new ArrayCollection();
  54.         $this->documentModels = new ArrayCollection();
  55.         $this->registrations = new ArrayCollection();
  56.         $this->profilings = new ArrayCollection();
  57.         $this->profilingPersons = new ArrayCollection();
  58.         $this->envelopes = new ArrayCollection();
  59.         $this->slots = new ArrayCollection();
  60.     }
  61.     public function getId(): ?int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getSection(): ?Section
  66.     {
  67.         return $this->section;
  68.     }
  69.     public function setSection(?Section $section): self
  70.     {
  71.         $this->section $section;
  72.         return $this;
  73.     }
  74.     public function getName(): ?string
  75.     {
  76.         if ($this->name) {
  77.             return $this->name;
  78.         }
  79.         if ($this->getStartAt() && $this->getEndAt()) {
  80.             return sprintf('%s-%s'$this->getStartAt()->format('Y'), $this->getEndAt()->format('Y'));
  81.         }
  82.         return null;
  83.     }
  84.     public function setName(?string $name): self
  85.     {
  86.         $this->name $name;
  87.         return $this;
  88.     }
  89.     public function getStartAt(): ?\DateTimeImmutable
  90.     {
  91.         return $this->startAt;
  92.     }
  93.     public function setStartAt(\DateTimeImmutable $startAt): self
  94.     {
  95.         $this->startAt $startAt;
  96.         return $this;
  97.     }
  98.     public function getEndAt(): ?\DateTimeImmutable
  99.     {
  100.         return $this->endAt;
  101.     }
  102.     public function setEndAt(\DateTimeImmutable $endAt): self
  103.     {
  104.         $this->endAt $endAt;
  105.         return $this;
  106.     }
  107.     public function getIsActive(): ?bool
  108.     {
  109.         return $this->isActive;
  110.     }
  111.     public function setIsActive(bool $isActive): self
  112.     {
  113.         $this->isActive $isActive;
  114.         return $this;
  115.     }
  116.     public function getGlobalSeason(): ?GlobalSeason
  117.     {
  118.         return $this->globalSeason;
  119.     }
  120.     public function setGlobalSeason(?GlobalSeason $globalSeason): self
  121.     {
  122.         $this->globalSeason $globalSeason;
  123.         return $this;
  124.     }
  125.     public function getPreviousSeason(): ?self
  126.     {
  127.         return $this->previousSeason;
  128.     }
  129.     public function setPreviousSeason(?self $previousSeason): self
  130.     {
  131.         $this->previousSeason $previousSeason;
  132.         return $this;
  133.     }
  134.     public function getNextSeason(): ?self
  135.     {
  136.         return $this->nextSeason;
  137.     }
  138.     public function setNextSeason(?self $nextSeason): self
  139.     {
  140.         // unset the owning side of the relation if necessary
  141.         if ($nextSeason === null && $this->nextSeason !== null) {
  142.             $this->nextSeason->setPreviousSeason(null);
  143.         }
  144.         // set the owning side of the relation if necessary
  145.         if ($nextSeason !== null && $nextSeason->getPreviousSeason() !== $this) {
  146.             $nextSeason->setPreviousSeason($this);
  147.         }
  148.         $this->nextSeason $nextSeason;
  149.         return $this;
  150.     }
  151.     /**
  152.      * @return Collection<int, Coach>
  153.      */
  154.     public function getCoaches(): Collection
  155.     {
  156.         return $this->coaches;
  157.     }
  158.     public function addCoach(Coach $coach): self
  159.     {
  160.         if (!$this->coaches->contains($coach)) {
  161.             $this->coaches[] = $coach;
  162.             $coach->setSeason($this);
  163.         }
  164.         return $this;
  165.     }
  166.     public function removeCoach(Coach $coach): self
  167.     {
  168.         if ($this->coaches->removeElement($coach)) {
  169.             // set the owning side to null (unless already changed)
  170.             if ($coach->getSeason() === $this) {
  171.                 $coach->setSeason(null);
  172.             }
  173.         }
  174.         return $this;
  175.     }
  176.     /**
  177.      * @return Collection<int, Lesson>
  178.      */
  179.     public function getLessons(): Collection
  180.     {
  181.         return $this->lessons;
  182.     }
  183.     public function addLesson(Lesson $lesson): self
  184.     {
  185.         if (!$this->lessons->contains($lesson)) {
  186.             $this->lessons[] = $lesson;
  187.             $lesson->setSeason($this);
  188.         }
  189.         return $this;
  190.     }
  191.     public function removeLesson(Lesson $lesson): self
  192.     {
  193.         if ($this->lessons->removeElement($lesson)) {
  194.             // set the owning side to null (unless already changed)
  195.             if ($lesson->getSeason() === $this) {
  196.                 $lesson->setSeason(null);
  197.             }
  198.         }
  199.         return $this;
  200.     }
  201.     /**
  202.      * @param bool|null $includeDiscounts
  203.      * @return Collection<int, DocumentModel>
  204.      */
  205.     public function getDocumentModels(?bool $includeDiscounts true): Collection
  206.     {
  207.         if (false === $includeDiscounts) {
  208.             return $this->documentModels->filter(fn(DocumentModel $d) => $d->getDiscountModel() === null);
  209.         }
  210.         return $this->documentModels;
  211.     }
  212.     public function addDocumentModel(DocumentModel $documentModel): self
  213.     {
  214.         if (!$this->documentModels->contains($documentModel)) {
  215.             $this->documentModels[] = $documentModel;
  216.             $documentModel->setSeason($this);
  217.         }
  218.         return $this;
  219.     }
  220.     public function removeDocumentModel(DocumentModel $documentModel): self
  221.     {
  222.         if ($this->documentModels->removeElement($documentModel)) {
  223.             // set the owning side to null (unless already changed)
  224.             if ($documentModel->getSeason() === $this) {
  225.                 $documentModel->setSeason(null);
  226.             }
  227.         }
  228.         return $this;
  229.     }
  230.     public function __toString(): string
  231.     {
  232.         return sprintf(
  233.             '%s %s - %s (%s)',
  234.             $this->getSection()?->getName(),
  235.             $this->getStartAt()?->format('d/m/Y'),
  236.             $this->getEndAt()?->format('d/m/Y'),
  237.             $this->name ?? 'N/A',
  238.         );
  239.     }
  240.     /**
  241.      * @return Collection<int, Registration>
  242.      */
  243.     public function getRegistrations(): Collection
  244.     {
  245.         return $this->registrations;
  246.     }
  247.     public function addRegistration(Registration $registration): self
  248.     {
  249.         if (!$this->registrations->contains($registration)) {
  250.             $this->registrations[] = $registration;
  251.             $registration->setSeason($this);
  252.         }
  253.         return $this;
  254.     }
  255.     public function removeRegistration(Registration $registration): self
  256.     {
  257.         if ($this->registrations->removeElement($registration)) {
  258.             // set the owning side to null (unless already changed)
  259.             if ($registration->getSeason() === $this) {
  260.                 $registration->setSeason(null);
  261.             }
  262.         }
  263.         return $this;
  264.     }
  265.     /**
  266.      * @return Collection<int, Profiling>
  267.      */
  268.     public function getProfilings(): Collection
  269.     {
  270.         return $this->profilings;
  271.     }
  272.     public function addProfiling(Profiling $profiling): self
  273.     {
  274.         if (!$this->profilings->contains($profiling)) {
  275.             $this->profilings[] = $profiling;
  276.             $profiling->setSeason($this);
  277.         }
  278.         return $this;
  279.     }
  280.     public function removeProfiling(Profiling $profiling): self
  281.     {
  282.         if ($this->profilings->removeElement($profiling)) {
  283.             // set the owning side to null (unless already changed)
  284.             if ($profiling->getSeason() === $this) {
  285.                 $profiling->setSeason(null);
  286.             }
  287.         }
  288.         return $this;
  289.     }
  290.     /**
  291.      * @return Collection<int, ProfilingPerson>
  292.      */
  293.     public function getProfilingPersons(): Collection
  294.     {
  295.         return $this->profilingPersons;
  296.     }
  297.     public function addProfilingPerson(ProfilingPerson $profilingPerson): self
  298.     {
  299.         if (!$this->profilingPersons->contains($profilingPerson)) {
  300.             $this->profilingPersons[] = $profilingPerson;
  301.             $profilingPerson->setSeason($this);
  302.         }
  303.         return $this;
  304.     }
  305.     public function removeProfilingPerson(ProfilingPerson $profilingPerson): self
  306.     {
  307.         if ($this->profilingPersons->removeElement($profilingPerson)) {
  308.             // set the owning side to null (unless already changed)
  309.             if ($profilingPerson->getSeason() === $this) {
  310.                 $profilingPerson->setSeason(null);
  311.             }
  312.         }
  313.         return $this;
  314.     }
  315.     /**
  316.      * @return Collection<int, Envelope>
  317.      */
  318.     public function getEnvelopes(): Collection
  319.     {
  320.         return $this->envelopes;
  321.     }
  322.     public function addEnvelope(Envelope $envelope): self
  323.     {
  324.         if (!$this->envelopes->contains($envelope)) {
  325.             $this->envelopes[] = $envelope;
  326.             $envelope->setSeason($this);
  327.         }
  328.         return $this;
  329.     }
  330.     public function removeEnvelope(Envelope $envelope): self
  331.     {
  332.         if ($this->envelopes->removeElement($envelope)) {
  333.             // set the owning side to null (unless already changed)
  334.             if ($envelope->getSeason() === $this) {
  335.                 $envelope->setSeason(null);
  336.             }
  337.         }
  338.         return $this;
  339.     }
  340.     /**
  341.      * @return Collection<int, Slot>
  342.      */
  343.     public function getSlots(): Collection
  344.     {
  345.         return $this->slots;
  346.     }
  347.     public function addSlot(Slot $slot): self
  348.     {
  349.         if (!$this->slots->contains($slot)) {
  350.             $this->slots[] = $slot;
  351.             $slot->setSeason($this);
  352.         }
  353.         return $this;
  354.     }
  355.     public function removeSlot(Slot $slot): self
  356.     {
  357.         if ($this->slots->removeElement($slot)) {
  358.             // set the owning side to null (unless already changed)
  359.             if ($slot->getSeason() === $this) {
  360.                 $slot->setSeason(null);
  361.             }
  362.         }
  363.         return $this;
  364.     }
  365.     public function isMigrated(): ?bool
  366.     {
  367.         return $this->migrated;
  368.     }
  369.     public function setMigrated(bool $migrated): self
  370.     {
  371.         $this->migrated $migrated;
  372.         return $this;
  373.     }
  374. }