165 lines
3.0 KiB
PHP
165 lines
3.0 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Gedmo\Mapping\Annotation as Gedmo;
|
|
use JsonSerializable;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(
|
|
* name="judges",
|
|
* indexes={
|
|
* @ORM\Index(name="j_name_idx", columns={"name"})
|
|
* }
|
|
* )
|
|
*/
|
|
class Judge implements JsonSerializable
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
* @ORM\Column(type="integer")
|
|
* @var int
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(name="name", type="string", length=250)
|
|
* @var string
|
|
*/
|
|
private $name;
|
|
|
|
/**
|
|
* @ORM\Column(name="slug", type="string", length=250)
|
|
* @Gedmo\Slug(fields={"name"})
|
|
* @var string
|
|
*/
|
|
private $slug;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="JudgeTitle", mappedBy="judge")
|
|
* @var Collection|JudgeTitle[]
|
|
*/
|
|
private $titles;
|
|
|
|
|
|
public function __construct()
|
|
{
|
|
$this->titles = new ArrayCollection();
|
|
}
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
public function getId(): int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* @param int $id
|
|
* @return Judge
|
|
*/
|
|
public function setId(int $id): Judge
|
|
{
|
|
$this->id = $id;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getName(): string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
/**
|
|
* @param string $name
|
|
* @return Judge
|
|
*/
|
|
public function setName(string $name): Judge
|
|
{
|
|
$this->name = $name;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getSlug(): string
|
|
{
|
|
return $this->slug;
|
|
}
|
|
|
|
/**
|
|
* @param string $slug
|
|
* @return Judge
|
|
*/
|
|
public function setSlug(string $slug): Judge
|
|
{
|
|
$this->slug = $slug;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return JudgeTitle[]|Collection
|
|
*/
|
|
public function getTitles()
|
|
{
|
|
return $this->titles;
|
|
}
|
|
|
|
/**
|
|
* @param JudgeTitle $title
|
|
* @return Judge
|
|
*/
|
|
public function addTitle(JudgeTitle $title): Judge
|
|
{
|
|
if(!$this->titles->contains($title)) {
|
|
$this->titles->add($title);
|
|
}
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param JudgeTitle $title
|
|
* @return Judge
|
|
*/
|
|
public function removeTitle(JudgeTitle $title): Judge
|
|
{
|
|
if($this->titles->contains($title)) {
|
|
$this->titles->removeElement($title);
|
|
}
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param JudgeTitle[]|Collection $titles
|
|
* @return Judge
|
|
*/
|
|
public function setTitles($titles)
|
|
{
|
|
$this->titles = $titles;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function jsonSerialize()
|
|
{
|
|
return [
|
|
'id' => $this->getId(),
|
|
'name' => $this->getName(),
|
|
'titles' => $this->getTitles()->getValues(),
|
|
'slug' => $this->getSlug(),
|
|
];
|
|
}
|
|
}
|