<?php
namespace App\Entity\Federation;
use App\Entity\Media\Document;
use App\Entity\Site\AccessSite;
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;
/**
* @ORM\Entity(repositoryClass="App\Repository\Federation\BoatRepository")
* @ORM\Table(name="boats")
*/
class Boat
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=false)
* @Assert\NotBlank()
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $number;
/**
* @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;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Federation\Participation", mappedBy="boat", cascade={"remove"})
*/
private $participations;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Federation\Classe", inversedBy="boats", cascade={"persist"})
* @ORM\JoinColumn(name="classe_id", referencedColumnName="id", nullable=false)
* @Assert\NotBlank()
*/
private $classe;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Site\AccessSite", mappedBy="boats")
*/
private $accessSites;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Media\Document", mappedBy="boats")
*/
private $documents;
public function __construct()
{
$this->participations = new ArrayCollection();
$this->accessSites = new ArrayCollection();
$this->documents = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getNumber(): ?string
{
return $this->number;
}
public function setNumber(?string $number): self
{
$this->number = $number;
return $this;
}
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;
}
/**
* @return Collection|Participation[]
*/
public function getParticipations(): Collection
{
return $this->participations;
}
public function addParticipation(Participation $participation): self
{
if (!$this->participations->contains($participation)) {
$this->participations[] = $participation;
$participation->setBoat($this);
}
return $this;
}
public function removeParticipation(Participation $participation): self
{
if ($this->participations->contains($participation)) {
$this->participations->removeElement($participation);
// set the owning side to null (unless already changed)
if ($participation->getBoat() === $this) {
$participation->setBoat(null);
}
}
return $this;
}
public function getClasse(): ?Classe
{
return $this->classe;
}
public function setClasse(?Classe $classe): self
{
$this->classe = $classe;
return $this;
}
/**
* @return Collection|AccessSite[]
*/
public function getAccessSites(): Collection
{
return $this->accessSites;
}
public function addAccessSite(AccessSite $accessSite): self
{
if (!$this->accessSites->contains($accessSite)) {
$this->accessSites[] = $accessSite;
$accessSite->addBoat($this);
}
return $this;
}
public function removeAccessSite(AccessSite $accessSite): self
{
if ($this->accessSites->contains($accessSite)) {
$this->accessSites->removeElement($accessSite);
$accessSite->removeBoat($this);
}
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->addBoat($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
$document->removeBoat($this);
}
return $this;
}
public function __toString(): string
{
return $this->name ? $this->name : '';
}
}