Files
LaLiga-BackEnd/src/Entity/League.php
T
Daniel Guzman 65b02bc11e
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
Move points per match to season entity
2024-06-02 22:41:59 +02:00

200 lines
4.2 KiB
PHP

<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\LeagueRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: LeagueRepository::class)]
#[ORM\HasLifecycleCallbacks]
class League
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $logo = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $description = null;
#[ORM\Column(nullable: true)]
private ?bool $active = null;
#[ORM\OneToMany(mappedBy: 'league', targetEntity: Season::class)]
private Collection $seasons;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $city = null;
#[ORM\Column(nullable: true)]
private ?int $matchesBetweenTeams = null;
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?array $blockedMatchDates = null;
#[ORM\Column(nullable: true)]
private ?bool $isPublic = null;
public function __construct()
{
$this->seasons = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(?string $logo): static
{
$this->logo = $logo;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(?bool $active): static
{
$this->active = $active;
return $this;
}
/**
* @return Collection<int, Season>
*/
public function getSeasons(): Collection
{
return $this->seasons;
}
public function addSeason(Season $season): static
{
if (!$this->seasons->contains($season)) {
$this->seasons->add($season);
$season->setLeague($this);
}
return $this;
}
public function removeSeason(Season $season): static
{
if ($this->seasons->removeElement($season)) {
// set the owning side to null (unless already changed)
if ($season->getLeague() === $this) {
$season->setLeague(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
#[ORM\PrePersist]
public function setCreatedAt(): void
{
$timezone = new \DateTimeZone('Europe/Madrid');
$this->createdAt = new \DateTimeImmutable('now', $timezone);
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): static
{
$this->city = $city;
return $this;
}
public function getMatchesBetweenTeams(): ?int
{
return $this->matchesBetweenTeams;
}
public function setMatchesBetweenTeams(?int $matchesBetweenTeams): static
{
$this->matchesBetweenTeams = $matchesBetweenTeams;
return $this;
}
public function getBlockedMatchDates(): ?array
{
return $this->blockedMatchDates;
}
public function setBlockedMatchDates(?array $blockedMatchDates): static
{
$this->blockedMatchDates = $blockedMatchDates;
return $this;
}
public function isPublic(): ?bool
{
return $this->isPublic;
}
public function setIsPublic(?bool $isPublic): static
{
$this->isPublic = $isPublic;
return $this;
}
}