Extend Leaderboard entity with backward relation to LeaderboardEntry entity
This commit is contained in:
parent
8220fdc893
commit
9fc7564f28
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Reference in New Issue