gamesshop/src/php/Entities/GamesList.php

78 lines
No EOL
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace GamesShop\Entities;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use GamesShop\Entities\Account\User;
#[ORM\Entity]
#[ORM\Table(name: 'games_lists')]
class GamesList
{
#[ORM\Id]
#[ORM\Column(type: 'integer', options: ['unsigned' => true])]
#[ORM\GeneratedValue]
private int|null $id;
#[ORM\ManyToOne]
private User $owner;
#[ORM\Column(nullable: true)]
private string|null $name;
#[ORM\JoinTable(name: 'games_list_claimer')]
#[ORM\JoinColumn(name: 'id', referencedColumnName: 'id')]
#[ORM\ManyToMany(targetEntity: User::class)]
private Collection $claimer;
#[ORM\Column(type: 'integer', options: ['unsigned' => true, 'default' => 0])]
private bool $isPublic = false;
/**
* @param User $owner
* @param string|null $name
*/
public function __construct(User $owner, ?string $name)
{
$this->owner = $owner;
$this->name = $name;
$this->claimer = new ArrayCollection([$owner]);
}
public function getId(): ?int
{
return $this->id;
}
public function getOwner(): User
{
return $this->owner;
}
public function getName(): ?string
{
return $this->name;
}
public function getClaimer(): Collection
{
return $this->claimer;
}
public function isPublic(): bool {
return $this->isPublic;
}
public function setIsPublic(bool $isPublic): void {
$this->isPublic = $isPublic;
}
public function addClaimer(User $claimer): void
{
$this->claimer[] = $claimer;
}
}