1
0
Fork 0

Extend Leaderboard entity with backward relation to LeaderboardEntry entity

This commit is contained in:
Krzysztof Sikorski 2022-04-25 23:52:36 +02:00
parent 8220fdc893
commit 9fc7564f28
Signed by: krzysztof-sikorski
GPG Key ID: 4EB564BD08FE8476
2 changed files with 13 additions and 2 deletions

View File

@ -10,6 +10,8 @@ use App\Contract\Doctrine\Entity\UuidPrimaryKeyInterface;
use App\Contract\Entity\Nexus\GamePeriodInterface;
use App\Doctrine\Entity\DatedEntityTrait;
use App\Doctrine\Entity\UuidPrimaryKeyTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[
@ -34,11 +36,15 @@ class Leaderboard implements UuidPrimaryKeyInterface, GamePeriodReferenceInterfa
ORM\ManyToOne(targetEntity: GamePeriod::class),
ORM\JoinColumn(name: 'game_period_id', referencedColumnName: 'id', nullable: false),
]
protected ?GamePeriodInterface $gamePeriod = null;
private ?GamePeriodInterface $gamePeriod = null;
#[ORM\OneToMany(mappedBy: 'leaderboard', targetEntity: LeaderboardEntry::class)]
private Collection $entries;
public function __construct()
{
$this->generateId();
$this->entries = new ArrayCollection();
}
public function getCategory(): ?LeaderboardCategory
@ -60,4 +66,9 @@ class Leaderboard implements UuidPrimaryKeyInterface, GamePeriodReferenceInterfa
{
$this->gamePeriod = $gamePeriod;
}
public function getEntries(): Collection
{
return $this->entries;
}
}

View File

@ -17,7 +17,7 @@ class LeaderboardEntry
{
#[
ORM\Id,
ORM\ManyToOne(targetEntity: Leaderboard::class),
ORM\ManyToOne(targetEntity: Leaderboard::class, inversedBy: 'entries'),
ORM\JoinColumn(name: 'leaderboard_id', referencedColumnName: 'id', nullable: false),
]
private ?Leaderboard $leaderboard = null;