welcome back to dyb-tech

This commit is contained in:
Daniel Guzman
2024-05-18 02:28:01 +02:00
parent 9513cdba09
commit 9f30bc98c7
6149 changed files with 668407 additions and 0 deletions
+122
View File
@@ -0,0 +1,122 @@
<?php
namespace DMD\LaLigaApi\Entity;
use DMD\LaLigaApi\Repository\FacilityRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: FacilityRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Facility
{
#[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 $address = null;
#[ORM\OneToMany(mappedBy: 'facility', targetEntity: Game::class)]
private Collection $games;
#[ORM\ManyToOne(inversedBy: 'facilities')]
private ?Season $season = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
public function __construct()
{
$this->games = 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 getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): static
{
$this->address = $address;
return $this;
}
/**
* @return Collection<int, Game>
*/
public function getGames(): Collection
{
return $this->games;
}
public function addGame(Game $game): static
{
if (!$this->games->contains($game)) {
$this->games->add($game);
$game->setFacility($this);
}
return $this;
}
public function removeGame(Game $game): static
{
if ($this->games->removeElement($game)) {
// set the owning side to null (unless already changed)
if ($game->getFacility() === $this) {
$game->setFacility(null);
}
}
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): static
{
$this->season = $season;
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);
}
}