<?php
namespace App\CasinoBundle\Entity;
use App\CmsBundle\Entity\IdTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\OrderBy;
/**
* @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\TeamRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Team
{
use IdTrait,
NameTrait,
PriorityTrait;
/**
* @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Author", mappedBy="team")
* @OrderBy({"priority" = "ASC"})
*/
public $members;
public function __construct()
{
$this->members = new ArrayCollection();
}
/**
* @return Collection|Author[]
*/
public function getMembers(): Collection
{
return $this->members;
}
public function addMember(Author $author): self
{
if (!$this->members->contains($author)) {
$this->members[] = $author;
$author->setTeam($this);
}
return $this;
}
public function removeMember(Author $author): self
{
if ($this->members->contains($author)) {
$this->members->removeElement($author);
if ($author->getTeam() === $this) {
$author->setTeam(null);
}
}
return $this;
}
}