src/Entity/GlobalSeason.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\GlobalSeasonRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassGlobalSeasonRepository::class)]
  8. class GlobalSeason
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\Column(type'date_immutable')]
  15.     private $startAt;
  16.     #[ORM\Column(type'date_immutable')]
  17.     private $endAt;
  18.     #[ORM\Column(type'boolean')]
  19.     private $isActive;
  20.     #[ORM\OneToMany(mappedBy'globalSeason'targetEntitySeason::class)]
  21.     private $seasons;
  22.     public function __construct()
  23.     {
  24.         $this->seasons = new ArrayCollection();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     public function getStartAt(): ?\DateTimeImmutable
  31.     {
  32.         return $this->startAt;
  33.     }
  34.     public function setStartAt(\DateTimeImmutable $startAt): self
  35.     {
  36.         $this->startAt $startAt;
  37.         return $this;
  38.     }
  39.     public function getEndAt(): ?\DateTimeImmutable
  40.     {
  41.         return $this->endAt;
  42.     }
  43.     public function setEndAt(\DateTimeImmutable $endAt): self
  44.     {
  45.         $this->endAt $endAt;
  46.         return $this;
  47.     }
  48.     public function getIsActive(): ?bool
  49.     {
  50.         return $this->isActive;
  51.     }
  52.     public function setIsActive(bool $isActive): self
  53.     {
  54.         $this->isActive $isActive;
  55.         return $this;
  56.     }
  57.     /**
  58.      * @return Collection<int, Season>
  59.      */
  60.     public function getSeasons(): Collection
  61.     {
  62.         return $this->seasons;
  63.     }
  64.     public function addSeason(Season $season): self
  65.     {
  66.         if (!$this->seasons->contains($season)) {
  67.             $this->seasons[] = $season;
  68.             $season->setGlobalSeason($this);
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeSeason(Season $season): self
  73.     {
  74.         if ($this->seasons->removeElement($season)) {
  75.             // set the owning side to null (unless already changed)
  76.             if ($season->getGlobalSeason() === $this) {
  77.                 $season->setGlobalSeason(null);
  78.             }
  79.         }
  80.         return $this;
  81.     }
  82.     public function __toString(): string
  83.     {
  84.         return sprintf('%s-%s'$this->getStartAt()?->format('Y'), $this->getEndAt()?->format('Y'));
  85.     }
  86. }