This commit is contained in:
2025-05-19 22:29:56 +02:00
parent 58bda32f09
commit e0350c8c31
26 changed files with 295 additions and 34 deletions

View File

@@ -23,7 +23,7 @@ class Answer
private Uuid $id;
#[ORM\Column(type: Types::SMALLINT, options: ['default' => 0])]
private int $ordering;
private int $ordering = 0;
#[ORM\ManyToOne(inversedBy: 'answers')]
#[ORM\JoinColumn(nullable: false)]

View File

@@ -14,6 +14,7 @@ use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: CandidateRepository::class)]
#[ORM\UniqueConstraint(fields: ['name', 'season'])]
class Candidate
{
#[ORM\Id]

View File

@@ -20,6 +20,10 @@ class Elimination
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private Uuid $id;
#[ORM\ManyToOne(inversedBy: 'eliminations')]
#[ORM\JoinColumn(nullable: false)]
private Quiz $quiz;
/** @var array<string, mixed> */
#[ORM\Column(type: Types::JSON)]
private array $data = [];
@@ -42,4 +46,16 @@ class Elimination
return $this;
}
public function setQuiz(Quiz $quiz): self
{
$this->quiz = $quiz;
return $this;
}
public function getQuiz(): Quiz
{
return $this->quiz;
}
}

View File

@@ -13,6 +13,7 @@ use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: QuizRepository::class)]
#[ORM\UniqueConstraint(fields: ['name', 'season'])]
class Quiz
{
#[ORM\Id]
@@ -40,10 +41,15 @@ class Quiz
#[ORM\Column(nullable: true)]
private ?int $dropouts = null;
/** @var Collection<int, Elimination> */
#[ORM\OneToMany(targetEntity: Elimination::class, mappedBy: 'quiz', cascade: ['persist'], orphanRemoval: true)]
private Collection $eliminations;
public function __construct()
{
$this->questions = new ArrayCollection();
$this->corrections = new ArrayCollection();
$this->eliminations = new ArrayCollection();
}
public function getId(): ?Uuid
@@ -118,4 +124,17 @@ class Quiz
return $this;
}
/** @return Collection<int, Elimination> */
public function getEliminations(): Collection
{
return $this->eliminations;
}
public function addElimination(Elimination $elimination): self
{
$this->eliminations->add($elimination);
return $this;
}
}

View File

@@ -35,6 +35,7 @@ class Season
/** @var Collection<int, Candidate> */
#[ORM\OneToMany(targetEntity: Candidate::class, mappedBy: 'season', cascade: ['persist'], orphanRemoval: true)]
#[ORM\OrderBy(['name' => 'ASC'])]
private Collection $candidates;
/** @var Collection<int, User> */

View File

@@ -7,6 +7,7 @@ namespace App\Entity;
use App\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\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Bridge\Doctrine\Types\UuidType;
@@ -31,7 +32,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
private string $email;
/** @var list<string> The user roles */
#[ORM\Column]
#[ORM\Column(type: Types::JSON)]
private array $roles = [];
/** @var string The hashed password */