welcome back to dyb-tech
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\CustomRoleRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: CustomRoleRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class CustomRole
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'customRoles')]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
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 getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
#[ORM\PrePersist]
|
||||
public function setCreatedAt(): static
|
||||
{
|
||||
$this->createdAt = new \DateTimeImmutable('now', new \DateTimeZone('Europe/Madrid'));
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\FileRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: FileRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class File
|
||||
{
|
||||
#[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 $type = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'files')]
|
||||
private ?Game $game = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'files')]
|
||||
private ?Player $player = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'files')]
|
||||
private ?Season $season = null;
|
||||
|
||||
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 getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(?string $type): static
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
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 getGame(): ?Game
|
||||
{
|
||||
return $this->game;
|
||||
}
|
||||
|
||||
public function setGame(?Game $game): static
|
||||
{
|
||||
$this->game = $game;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlayer(): ?Player
|
||||
{
|
||||
return $this->player;
|
||||
}
|
||||
|
||||
public function setPlayer(?Player $player): static
|
||||
{
|
||||
$this->player = $player;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSeason(): ?Season
|
||||
{
|
||||
return $this->season;
|
||||
}
|
||||
|
||||
public function setSeason(?Season $season): static
|
||||
{
|
||||
$this->season = $season;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\GameRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: GameRepository::class)]
|
||||
class Game
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $pointsHome = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $pointsAway = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $plannedDate = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $gameDateTime = null;
|
||||
|
||||
#[ORM\Column(length: 350, nullable: true)]
|
||||
private ?string $notes = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'game', targetEntity: File::class)]
|
||||
private Collection $files;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'games')]
|
||||
private ?Season $season = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'games')]
|
||||
private ?Facility $facility = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?Team $homeTeam = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
private ?Team $awayTeam = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->files = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPointsHome(): ?int
|
||||
{
|
||||
return $this->pointsHome;
|
||||
}
|
||||
|
||||
public function setPointsHome(?int $pointsHome): static
|
||||
{
|
||||
$this->pointsHome = $pointsHome;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPointsAway(): ?int
|
||||
{
|
||||
return $this->pointsAway;
|
||||
}
|
||||
|
||||
public function setPointsAway(?int $pointsAway): static
|
||||
{
|
||||
$this->pointsAway = $pointsAway;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPlannedDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->plannedDate;
|
||||
}
|
||||
|
||||
public function setPlannedDate(?\DateTimeInterface $plannedDate): static
|
||||
{
|
||||
$this->plannedDate = $plannedDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGameDateTime(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->gameDateTime;
|
||||
}
|
||||
|
||||
public function setGameDateTime(?\DateTimeInterface $gameDateTime): static
|
||||
{
|
||||
$this->gameDateTime = $gameDateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNotes(): ?string
|
||||
{
|
||||
return $this->notes;
|
||||
}
|
||||
|
||||
public function setNotes(?string $notes): static
|
||||
{
|
||||
$this->notes = $notes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, File>
|
||||
*/
|
||||
public function getFiles(): Collection
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
public function addFile(File $file): static
|
||||
{
|
||||
if (!$this->files->contains($file)) {
|
||||
$this->files->add($file);
|
||||
$file->setGame($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeFile(File $file): static
|
||||
{
|
||||
if ($this->files->removeElement($file)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($file->getGame() === $this) {
|
||||
$file->setGame(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSeason(): ?Season
|
||||
{
|
||||
return $this->season;
|
||||
}
|
||||
|
||||
public function setSeason(?Season $season): static
|
||||
{
|
||||
$this->season = $season;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFacility(): ?Facility
|
||||
{
|
||||
return $this->facility;
|
||||
}
|
||||
|
||||
public function setFacility(?Facility $facility): static
|
||||
{
|
||||
$this->facility = $facility;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHomeTeam(): ?Team
|
||||
{
|
||||
return $this->homeTeam;
|
||||
}
|
||||
|
||||
public function setHomeTeam(?Team $homeTeam): static
|
||||
{
|
||||
$this->homeTeam = $homeTeam;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAwayTeam(): ?Team
|
||||
{
|
||||
return $this->awayTeam;
|
||||
}
|
||||
|
||||
public function setAwayTeam(?Team $awayTeam): static
|
||||
{
|
||||
$this->awayTeam = $awayTeam;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
#[ORM\PrePersist]
|
||||
public function setCreatedAt(): static
|
||||
{
|
||||
$this->createdAt = new \DateTimeImmutable('now');
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): static
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
<?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(nullable: true)]
|
||||
private ?int $pointsPerWin = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $pointsPerDraw = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $city = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $pointsPerLoss = 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 getPointsPerWin(): ?int
|
||||
{
|
||||
return $this->pointsPerWin;
|
||||
}
|
||||
|
||||
public function setPointsPerWin(?int $pointsPerWin): static
|
||||
{
|
||||
$this->pointsPerWin = $pointsPerWin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPointsPerDraw(): ?int
|
||||
{
|
||||
return $this->pointsPerDraw;
|
||||
}
|
||||
|
||||
public function setPointsPerDraw(?int $pointsPerDraw): static
|
||||
{
|
||||
$this->pointsPerDraw = $pointsPerDraw;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCity(): ?string
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
public function setCity(?string $city): static
|
||||
{
|
||||
$this->city = $city;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPointsPerLoss(): ?int
|
||||
{
|
||||
return $this->pointsPerLoss;
|
||||
}
|
||||
|
||||
public function setPointsPerLoss(?int $pointsPerLoss): static
|
||||
{
|
||||
$this->pointsPerLoss = $pointsPerLoss;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\LogRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: LogRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class Log
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $payload = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $code = null;
|
||||
|
||||
#[ORM\Column(length: 550, nullable: true)]
|
||||
private ?string $message = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPayload(): ?string
|
||||
{
|
||||
return $this->payload;
|
||||
}
|
||||
|
||||
public function setPayload(?string $payload): static
|
||||
{
|
||||
$this->payload = $payload;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode(): ?int
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode(?int $code): static
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMessage(): ?string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function setMessage(?string $message): static
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\NotificationRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: NotificationRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class Notification
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $type = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'requestsSent')]
|
||||
private ?User $userWhoFiredEvent = null;
|
||||
|
||||
#[ORM\Column(length: 280, nullable: true)]
|
||||
private ?string $message = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'notifications')]
|
||||
private ?League $league = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $teamId = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'receivedNotifications')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $userToNotify = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $isRead = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $readAt = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(?string $type): static
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUserWhoFiredEvent(): ?User
|
||||
{
|
||||
return $this->userWhoFiredEvent;
|
||||
}
|
||||
|
||||
public function setUserWhoFiredEvent(?User $userWhoFiredEvent): static
|
||||
{
|
||||
$this->userWhoFiredEvent = $userWhoFiredEvent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMessage(): ?string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function setMessage(?string $message): static
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLeague(): ?League
|
||||
{
|
||||
return $this->league;
|
||||
}
|
||||
|
||||
public function setLeague(?League $league): static
|
||||
{
|
||||
$this->league = $league;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
#[ORM\PrePersist]
|
||||
public function setCreatedAt(): static
|
||||
{
|
||||
$this->createdAt = new \DateTimeImmutable('now', new \DateTimeZone('Europe/Madrid'));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTeamId(): ?int
|
||||
{
|
||||
return $this->teamId;
|
||||
}
|
||||
|
||||
public function setTeamId(?int $teamId): static
|
||||
{
|
||||
$this->teamId = $teamId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUserToNotify(): ?User
|
||||
{
|
||||
return $this->userToNotify;
|
||||
}
|
||||
|
||||
public function setUserToNotify(?User $userToNotify): static
|
||||
{
|
||||
$this->userToNotify = $userToNotify;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isIsRead(): ?bool
|
||||
{
|
||||
return $this->isRead;
|
||||
}
|
||||
|
||||
public function setIsRead(?bool $isRead): static
|
||||
{
|
||||
$this->isRead = $isRead;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReadAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->readAt;
|
||||
}
|
||||
|
||||
public function setReadAt(?\DateTimeImmutable $readAt): static
|
||||
{
|
||||
$this->readAt = $readAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\PlayerRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: PlayerRepository::class)]
|
||||
class Player
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $firstName = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $lastName = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $position = null;
|
||||
|
||||
#[ORM\Column(type: Types::SMALLINT, nullable: true)]
|
||||
private ?int $jerseyNumber = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $isFederated = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $pictureFileName = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $birthday = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'player', targetEntity: File::class)]
|
||||
private Collection $files;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'players')]
|
||||
private ?Team $team = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->files = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getFirstName(): ?string
|
||||
{
|
||||
return $this->firstName;
|
||||
}
|
||||
|
||||
public function setFirstName(?string $firstName): static
|
||||
{
|
||||
$this->firstName = $firstName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastName(): ?string
|
||||
{
|
||||
return $this->lastName;
|
||||
}
|
||||
|
||||
public function setLastName(?string $lastName): static
|
||||
{
|
||||
$this->lastName = $lastName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPosition(): ?string
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition(?string $position): static
|
||||
{
|
||||
$this->position = $position;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getJerseyNumber(): ?int
|
||||
{
|
||||
return $this->jerseyNumber;
|
||||
}
|
||||
|
||||
public function setJerseyNumber(?int $jerseyNumber): static
|
||||
{
|
||||
$this->jerseyNumber = $jerseyNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isIsFederated(): ?bool
|
||||
{
|
||||
return $this->isFederated;
|
||||
}
|
||||
|
||||
public function setIsFederated(?bool $isFederated): static
|
||||
{
|
||||
$this->isFederated = $isFederated;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPictureFileName(): ?string
|
||||
{
|
||||
return $this->pictureFileName;
|
||||
}
|
||||
|
||||
public function setPictureFileName(?string $pictureFileName): static
|
||||
{
|
||||
$this->pictureFileName = $pictureFileName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBirthday(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->birthday;
|
||||
}
|
||||
|
||||
public function setBirthday(?\DateTimeInterface $birthday): static
|
||||
{
|
||||
$this->birthday = $birthday;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, File>
|
||||
*/
|
||||
public function getFiles(): Collection
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
public function addFile(File $file): static
|
||||
{
|
||||
if (!$this->files->contains($file)) {
|
||||
$this->files->add($file);
|
||||
$file->setPlayer($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeFile(File $file): static
|
||||
{
|
||||
if ($this->files->removeElement($file)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($file->getPlayer() === $this) {
|
||||
$file->setPlayer(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTeam(): ?Team
|
||||
{
|
||||
return $this->team;
|
||||
}
|
||||
|
||||
public function setTeam(?Team $team): static
|
||||
{
|
||||
$this->team = $team;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\SeasonRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SeasonRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class Season
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
private ?\DateTimeInterface $dateStart = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $active = null;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Team::class, inversedBy: 'seasons')]
|
||||
private Collection $teams;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'seasons')]
|
||||
private ?League $league = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Game::class)]
|
||||
private Collection $games;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'season', targetEntity: Facility::class)]
|
||||
private Collection $facilities;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $updatedAt = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'season', targetEntity: File::class)]
|
||||
private Collection $files;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->teams = new ArrayCollection();
|
||||
$this->games = new ArrayCollection();
|
||||
$this->facilities = new ArrayCollection();
|
||||
$this->files = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Team>
|
||||
*/
|
||||
public function getTeams(): Collection
|
||||
{
|
||||
return $this->teams;
|
||||
}
|
||||
|
||||
public function addTeam(Team $team): static
|
||||
{
|
||||
if (!$this->teams->contains($team)) {
|
||||
$this->teams->add($team);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeTeam(Team $team): static
|
||||
{
|
||||
$this->teams->removeElement($team);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateStart(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->dateStart;
|
||||
}
|
||||
|
||||
public function setDateStart(\DateTimeInterface $dateStart): static
|
||||
{
|
||||
$this->dateStart = $dateStart;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateEnd(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->dateEnd;
|
||||
}
|
||||
|
||||
public function setDateEnd(?\DateTimeInterface $dateEnd): static
|
||||
{
|
||||
$this->dateEnd = $dateEnd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(?bool $active): static
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
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 getLeague(): ?League
|
||||
{
|
||||
return $this->league;
|
||||
}
|
||||
|
||||
public function setLeague(?League $league): static
|
||||
{
|
||||
$this->league = $league;
|
||||
|
||||
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->setSeason($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->getSeason() === $this) {
|
||||
$game->setSeason(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Facility>
|
||||
*/
|
||||
public function getFacilities(): Collection
|
||||
{
|
||||
return $this->facilities;
|
||||
}
|
||||
|
||||
public function addFacility(Facility $facility): static
|
||||
{
|
||||
if (!$this->facilities->contains($facility)) {
|
||||
$this->facilities->add($facility);
|
||||
$facility->setSeason($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeFacility(Facility $facility): static
|
||||
{
|
||||
if ($this->facilities->removeElement($facility)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($facility->getSeason() === $this) {
|
||||
$facility->setSeason(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, File>
|
||||
*/
|
||||
public function getFiles(): Collection
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
public function addFile(File $file): static
|
||||
{
|
||||
if (!$this->files->contains($file)) {
|
||||
$this->files->add($file);
|
||||
$file->setSeason($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeFile(File $file): static
|
||||
{
|
||||
if ($this->files->removeElement($file)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($file->getSeason() === $this) {
|
||||
$file->setSeason(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\SeasonDataRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SeasonDataRepository::class)]
|
||||
class SeasonData
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'seasonData')]
|
||||
private ?Team $team = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $points = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'seasonData')]
|
||||
private ?Season $season = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTeam(): ?Team
|
||||
{
|
||||
return $this->team;
|
||||
}
|
||||
|
||||
public function setTeam(?Team $team): static
|
||||
{
|
||||
$this->team = $team;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPoints(): ?int
|
||||
{
|
||||
return $this->points;
|
||||
}
|
||||
|
||||
public function setSeasonPoints(?int $points): static
|
||||
{
|
||||
$this->points = $points;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSeason(): ?Season
|
||||
{
|
||||
return $this->season;
|
||||
}
|
||||
|
||||
public function setSeason(?Season $season): static
|
||||
{
|
||||
$this->season = $season;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPoints(?int $points): static
|
||||
{
|
||||
$this->points = $points;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\TeamRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TeamRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class Team
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $active = null;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Season::class, mappedBy: 'teams')]
|
||||
private Collection $seasons;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'team', targetEntity: SeasonData::class)]
|
||||
private Collection $seasonData;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'team', targetEntity: Player::class)]
|
||||
private Collection $players;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
#[ORM\OneToOne(inversedBy: 'team', cascade: ['persist', 'remove'])]
|
||||
private ?User $captain = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->seasons = new ArrayCollection();
|
||||
$this->seasonData = new ArrayCollection();
|
||||
$this->players = 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 isActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(?bool $active): static
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
#[ORM\PrePersist]
|
||||
public function setCreatedAt(): void
|
||||
{
|
||||
$this->createdAt = new \DateTimeImmutable();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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->addTeam($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSeason(Season $season): static
|
||||
{
|
||||
if ($this->seasons->removeElement($season)) {
|
||||
$season->removeTeam($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Collection<int, SeasonData>
|
||||
*/
|
||||
public function getSeasonData(): Collection
|
||||
{
|
||||
return $this->seasonData;
|
||||
}
|
||||
|
||||
public function addSeasonData(SeasonData $seasonData): static
|
||||
{
|
||||
if (!$this->seasonData->contains($seasonData)) {
|
||||
$this->seasonData->add($seasonData);
|
||||
$seasonData->setTeam($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSeasonData(SeasonData $seasonData): static
|
||||
{
|
||||
if ($this->seasonData->removeElement($seasonData)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($seasonData->getTeam() === $this) {
|
||||
$seasonData->setTeam(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Player>
|
||||
*/
|
||||
public function getPlayers(): Collection
|
||||
{
|
||||
return $this->players;
|
||||
}
|
||||
|
||||
public function addPlayer(Player $player): static
|
||||
{
|
||||
if (!$this->players->contains($player)) {
|
||||
$this->players->add($player);
|
||||
$player->setTeam($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePlayer(Player $player): static
|
||||
{
|
||||
if ($this->players->removeElement($player)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($player->getTeam() === $this) {
|
||||
$player->setTeam(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCaptain(): ?User
|
||||
{
|
||||
return $this->captain;
|
||||
}
|
||||
|
||||
public function setCaptain(?User $captain): static
|
||||
{
|
||||
$this->captain = $captain;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
namespace DMD\LaLigaApi\Entity;
|
||||
|
||||
use DMD\LaLigaApi\Repository\UserRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 180, unique: true)]
|
||||
private ?string $email = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private array $roles = [];
|
||||
|
||||
#[ORM\Column]
|
||||
private ?string $password = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $firstName = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $lastName = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $phone = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $profilePicture = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $birthday = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $active = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
#[ORM\Column(type: Types::ARRAY, nullable: true)]
|
||||
private ?array $noteList = null;
|
||||
|
||||
#[ORM\OneToOne(mappedBy: 'captain', cascade: ['persist', 'remove'])]
|
||||
private ?Team $team = null;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'userWhoFiredEvent', targetEntity: Notification::class)]
|
||||
private Collection $sentNotifications;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'user', targetEntity: CustomRole::class, cascade: ['persist', 'remove'])]
|
||||
private Collection $customRoles;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'userToNotify', targetEntity: Notification::class, orphanRemoval: true)]
|
||||
private Collection $receivedNotifications;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->sentNotifications = new ArrayCollection();
|
||||
$this->customRoles = new ArrayCollection();
|
||||
$this->receivedNotifications = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): static
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A visual identifier that represents this user.
|
||||
*
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function getUserIdentifier(): string
|
||||
{
|
||||
return (string) $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function getRoles(): array
|
||||
{
|
||||
$roles = $this->roles;
|
||||
// guarantee every user at least has ROLE_USER
|
||||
$roles[] = 'ROLE_USER';
|
||||
|
||||
return array_unique($roles);
|
||||
}
|
||||
|
||||
public function setRoles(array $roles): static
|
||||
{
|
||||
$this->roles = $roles;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PasswordAuthenticatedUserInterface
|
||||
*/
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword(string $password): static
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function eraseCredentials(): void
|
||||
{
|
||||
// If you store any temporary, sensitive data on the user, clear it here
|
||||
// $this->plainPassword = null;
|
||||
}
|
||||
|
||||
public function getFirstName(): ?string
|
||||
{
|
||||
return $this->firstName;
|
||||
}
|
||||
|
||||
public function setFirstName(?string $firstName): static
|
||||
{
|
||||
$this->firstName = $firstName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastName(): ?string
|
||||
{
|
||||
return $this->lastName;
|
||||
}
|
||||
|
||||
public function setLastName(?string $lastName): static
|
||||
{
|
||||
$this->lastName = $lastName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPhone(): ?string
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
public function setPhone(?string $phone): static
|
||||
{
|
||||
$this->phone = $phone;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProfilePicture(): ?string
|
||||
{
|
||||
return $this->profilePicture;
|
||||
}
|
||||
|
||||
public function setProfilePicture(?string $profilePicture): static
|
||||
{
|
||||
$this->profilePicture = $profilePicture;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBirthday(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->birthday;
|
||||
}
|
||||
|
||||
public function setBirthday(?\DateTimeInterface $birthday): static
|
||||
{
|
||||
$this->birthday = $birthday;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isActive(): ?bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(?bool $active): static
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
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 getNoteList(): ?array
|
||||
{
|
||||
return $this->noteList;
|
||||
}
|
||||
|
||||
public function setNoteList(?array $noteList): static
|
||||
{
|
||||
$this->noteList = $noteList;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTeam(): ?Team
|
||||
{
|
||||
return $this->team;
|
||||
}
|
||||
|
||||
public function setTeam(?Team $team): static
|
||||
{
|
||||
// unset the owning side of the relation if necessary
|
||||
if ($team === null && $this->team !== null) {
|
||||
$this->team->setCaptain(null);
|
||||
}
|
||||
|
||||
// set the owning side of the relation if necessary
|
||||
if ($team !== null && $team->getCaptain() !== $this) {
|
||||
$team->setCaptain($this);
|
||||
}
|
||||
|
||||
$this->team = $team;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Notification>
|
||||
*/
|
||||
public function getSentNotifications(): Collection
|
||||
{
|
||||
return $this->sentNotifications;
|
||||
}
|
||||
|
||||
public function addSentNotifications(Notification $sentNotifications): static
|
||||
{
|
||||
if (!$this->sentNotifications->contains($sentNotifications)) {
|
||||
$this->sentNotifications->add($sentNotifications);
|
||||
$sentNotifications->setUserWhoFiredEvent($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSentNotifications(Notification $sentNotifications): static
|
||||
{
|
||||
if ($this->sentNotifications->removeElement($sentNotifications)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($sentNotifications->getUserWhoFiredEvent() === $this) {
|
||||
$sentNotifications->setUserWhoFiredEvent(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, CustomRole>
|
||||
*/
|
||||
public function getCustomRoles(): Collection
|
||||
{
|
||||
return $this->customRoles;
|
||||
}
|
||||
|
||||
public function addCustomRole(CustomRole $customRole): static
|
||||
{
|
||||
if (!$this->customRoles->contains($customRole)) {
|
||||
$this->customRoles->add($customRole);
|
||||
$customRole->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeCustomRole(CustomRole $customRole): static
|
||||
{
|
||||
if ($this->customRoles->removeElement($customRole)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($customRole->getUser() === $this) {
|
||||
$customRole->setUser(null);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Notification>
|
||||
*/
|
||||
public function getReceivedNotifications(): Collection
|
||||
{
|
||||
return $this->receivedNotifications;
|
||||
}
|
||||
|
||||
public function addReceivedNotification(Notification $receivedNotification): static
|
||||
{
|
||||
if (!$this->receivedNotifications->contains($receivedNotification)) {
|
||||
$this->receivedNotifications->add($receivedNotification);
|
||||
$receivedNotification->setUserToNotify($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeReceivedNotification(Notification $receivedNotification): static
|
||||
{
|
||||
if ($this->receivedNotifications->removeElement($receivedNotification)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($receivedNotification->getUserToNotify() === $this) {
|
||||
$receivedNotification->setUserToNotify(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user