You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
2.4 KiB
112 lines
2.4 KiB
<?php
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\TournamentRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: TournamentRepository::class)]
|
|
class Tournament extends Thing
|
|
{
|
|
|
|
#[ORM\Column(length: 255)]
|
|
public string $name;
|
|
|
|
#[ORM\ManyToMany(targetEntity: Character::class)]
|
|
public Collection $characters;
|
|
|
|
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
|
private ?\DateTimeInterface $startDate = null;
|
|
|
|
#[ORM\OneToMany(mappedBy: 'tournament', targetEntity: Fight::class)]
|
|
private Collection $fights;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->characters = new ArrayCollection();
|
|
$this->fights = new ArrayCollection();
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): static
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return Collection<int, Character>
|
|
*/
|
|
public function getCharacters(): Collection
|
|
{
|
|
return $this->characters;
|
|
}
|
|
|
|
public function addCharacter(Character $character): static
|
|
{
|
|
if (! $this->characters->contains($character)) {
|
|
$this->characters->add($character);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeCharacter(Character $character): static
|
|
{
|
|
$this->characters->removeElement($character);
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStartDate(): ?\DateTimeInterface
|
|
{
|
|
return $this->startDate;
|
|
}
|
|
|
|
public function setStartDate(\DateTimeInterface $startDate): static
|
|
{
|
|
$this->startDate = $startDate;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return Collection<int, Fight>
|
|
*/
|
|
public function getFights(): Collection
|
|
{
|
|
return $this->fights;
|
|
}
|
|
|
|
public function addFight(Fight $fight): static
|
|
{
|
|
if (! $this->fights->contains($fight)) {
|
|
$this->fights->add($fight);
|
|
$fight->setTournament($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeFight(Fight $fight): static
|
|
{
|
|
if ($this->fights->removeElement($fight)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($fight->getTournament() === $this) {
|
|
$fight->setTournament(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|