| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\User;
- use ApiPlatform\Metadata\ApiResource;
- use Doctrine\DBAL\Types\Types;
- use Doctrine\ORM\Mapping as ORM;
- #[ORM\Entity]
- #[ORM\Table(name: 'game_participations')]
- #[ORM\UniqueConstraint(name: 'unique_user_game', columns: ['user_id', 'game_id'])]
- #[ApiResource]
- class GameParticipation
- {
- #[ORM\Id]
- #[ORM\GeneratedValue]
- #[ORM\Column]
- private ?int $id = null;
- #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'gameParticipations')]
- #[ORM\JoinColumn(nullable: false)]
- private User $user;
- #[ORM\ManyToOne(targetEntity: Game::class, inversedBy: 'gameParticipations')]
- #[ORM\JoinColumn(nullable: false)]
- private Game $game;
- #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
- private \DateTimeImmutable $joinedAt;
- #[ORM\Column(length: 20, nullable: false, options: ['default' => 'active'])]
- private string $status = 'active';
- #[ORM\Column(nullable: true)]
- private ?int $score = null;
- #[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
- private ?\DateTimeImmutable $lastPlayedAt = null;
- public function __construct()
- {
- $this->joinedAt = new \DateTimeImmutable();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getUser(): User
- {
- return $this->user;
- }
- public function setUser(User $user): self
- {
- $this->user = $user;
- return $this;
- }
- public function getGame(): Game
- {
- return $this->game;
- }
- public function setGame(Game $game): self
- {
- $this->game = $game;
- return $this;
- }
- public function getJoinedAt(): \DateTimeImmutable
- {
- return $this->joinedAt;
- }
- public function setJoinedAt(\DateTimeImmutable $joinedAt): self
- {
- $this->joinedAt = $joinedAt;
- return $this;
- }
- public function getStatus(): string
- {
- return $this->status;
- }
- public function setStatus(string $status): self
- {
- $this->status = $status;
- return $this;
- }
- public function getScore(): ?int
- {
- return $this->score;
- }
- public function setScore(?int $score): self
- {
- $this->score = $score;
- return $this;
- }
- public function getLastPlayedAt(): ?\DateTimeImmutable
- {
- return $this->lastPlayedAt;
- }
- public function setLastPlayedAt(?\DateTimeImmutable $lastPlayedAt): self
- {
- $this->lastPlayedAt = $lastPlayedAt;
- return $this;
- }
- }
|