<?php
namespace App\Entity\Federation;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Entity\User\User;
/**
* @ORM\Entity(repositoryClass="App\Repository\Federation\ParticipationRepository")
* @ORM\Table(name="participations")
* @UniqueEntity(fields={"boat", "race"}, message="participation.boat")
* @UniqueEntity(fields={"skipper", "race"}, message="participation.skipper")
*/
class Participation
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Federation\Skipper", inversedBy="participations", cascade={"persist"})
* @ORM\JoinColumn(name="skipper_id", referencedColumnName="id")
* @Assert\NotBlank()
*/
private $skipper;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Federation\Race", inversedBy="participations")
* @ORM\JoinColumn(name="race_id", referencedColumnName="id")
* @Assert\NotBlank()
*/
private $race;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Federation\Boat", inversedBy="participations", cascade={"persist"})
* @ORM\JoinColumn(name="boat_id", referencedColumnName="id")
* @Assert\NotBlank()
*/
private $boat;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\User\User", inversedBy="participations"))
* @ORM\JoinTable(name="participations_referents")
* @ORM\JoinColumn(nullable=true)
*/
private $referents;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Federation\Team", cascade={"persist"}, inversedBy="participations"))
* @ORM\JoinTable(name="participations_teams")
* @ORM\JoinColumn(nullable=true)
*/
private $teams;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_date")
* @Gedmo\Timestampable(on="create")
*/
private $createdDate;
/**
* @ORM\Column(type="datetime", nullable=true, name="updated_date")
* @Gedmo\Timestampable(on="update")
*/
private $updatedDate;
/**
* @ORM\Column(type="integer", nullable=true, name="status")
*/
private $status = 1;
public function __construct()
{
$this->teams = new ArrayCollection();
$this->referents = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCreatedDate(): ?\DateTimeInterface
{
return $this->createdDate;
}
public function getUpdatedDate(): ?\DateTimeInterface
{
return $this->updatedDate;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(?int $status): self
{
$this->status = $status;
return $this;
}
public function getSkipper(): ?Skipper
{
return $this->skipper;
}
public function setSkipper(?Skipper $skipper): self
{
$this->skipper = $skipper;
return $this;
}
public function getRace(): ?Race
{
return $this->race;
}
public function setRace(?Race $race): self
{
$this->race = $race;
return $this;
}
public function getBoat(): ?Boat
{
return $this->boat;
}
public function setBoat(?Boat $boat): self
{
$this->boat = $boat;
return $this;
}
/**
* @return Collection|User[]
*/
public function getReferents(): ?Collection
{
return $this->referents;
}
public function addReferent(User $referent): self
{
if (!$this->referents->contains($referent)) {
$this->referents[] = $referent;
}
return $this;
}
public function removeReferent(User $referent): self
{
if ($this->referents->contains($referent)) {
$this->referents->removeElement($referent);
}
return $this;
}
/**
* @return Collection|Team[]
*/
public function getTeams(): Collection
{
return $this->teams;
}
public function addTeam(Team $team): self
{
if (!$this->teams->contains($team)) {
$this->teams[] = $team;
}
return $this;
}
public function removeTeam(Team $team): self
{
if ($this->teams->contains($team)) {
$this->teams->removeElement($team);
}
return $this;
}
}