<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\EmplacementRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
#[ORM\Entity(repositoryClass: EmplacementRepository::class)]
class Emplacement
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string',length: 255)]
private $libelle;
#[ORM\Column(type: 'string',length: 255)]
private $adr;
#[ORM\Column(type: 'string',length: 5)]
private $cp;
#[ORM\Column(type: 'string',length: 255)]
private $ville;
#[ORM\OneToMany(mappedBy: 'emplacement', targetEntity: Service::class)]
private $services;
#[ORM\Column(type: 'string',length: 255, nullable: true)]
private $url;
#[ORM\OneToMany(mappedBy: 'emplacement', targetEntity: AccesEmplacement::class, cascade:['persist'], orphanRemoval: true)]
private Collection $accesEmplacements;
#[ORM\OneToMany(mappedBy: 'emplacement', targetEntity: Rotation::class, orphanRemoval: true)]
private Collection $rotations;
#[ORM\Column(nullable: true)]
private ?bool $public = null;
#[ORM\ManyToOne(inversedBy: 'emplacements')]
private ?User $createur = null;
public function __construct()
{
$this->services = new ArrayCollection();
$this->accesEmplacements = new ArrayCollection();
$this->rotations = new ArrayCollection();
}
public function __toString(): string
{
return $this->libelle;
}
public function getId(): ?int
{
return $this->id;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function setLibelle(string $libelle): self
{
$this->libelle = $libelle;
return $this;
}
public function getAdr(): ?string
{
return $this->adr;
}
public function setAdr(string $adr): self
{
$this->adr = $adr;
return $this;
}
public function getCp(): ?string
{
return $this->cp;
}
public function setCp(string $cp): self
{
$this->cp = $cp;
return $this;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(string $ville): self
{
$this->ville = $ville;
return $this;
}
/**
* @return Collection|Service[]
*/
public function getServices(): Collection
{
return $this->services;
}
public function addService(Service $service): self
{
if (!$this->services->contains($service)) {
$this->services[] = $service;
$service->setEmplacement($this);
}
return $this;
}
public function removeService(Service $service): self
{
if ($this->services->removeElement($service)) {
// set the owning side to null (unless already changed)
if ($service->getEmplacement() === $this) {
$service->setEmplacement(null);
}
}
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
/**
* @return Collection<int, AccesEmplacement>
*/
public function getAccesEmplacements(): Collection
{
return $this->accesEmplacements;
}
public function addAccesEmplacement(AccesEmplacement $accesEmplacement): self
{
if (!$this->accesEmplacements->contains($accesEmplacement)) {
$this->accesEmplacements->add($accesEmplacement);
$accesEmplacement->setEmplacement($this);
}
return $this;
}
public function removeAccesEmplacement(AccesEmplacement $accesEmplacement): self
{
if ($this->accesEmplacements->removeElement($accesEmplacement)) {
// set the owning side to null (unless already changed)
if ($accesEmplacement->getEmplacement() === $this) {
$accesEmplacement->setEmplacement(null);
}
}
return $this;
}
/**
* @return Collection<int, Rotation>
*/
public function getRotations(): Collection
{
return $this->rotations;
}
public function addRotation(Rotation $rotation): self
{
if (!$this->rotations->contains($rotation)) {
$this->rotations->add($rotation);
$rotation->setEmplacement($this);
}
return $this;
}
public function removeRotation(Rotation $rotation): self
{
if ($this->rotations->removeElement($rotation)) {
// set the owning side to null (unless already changed)
if ($rotation->getEmplacement() === $this) {
$rotation->setEmplacement(null);
}
}
return $this;
}
public function isPublic(): ?bool
{
return $this->public;
}
public function setPublic(?bool $public): static
{
$this->public = $public;
return $this;
}
public function getCreateur(): ?User
{
return $this->createur;
}
public function setCreateur(?User $createur): static
{
$this->createur = $createur;
return $this;
}
}