<?php
namespace App\Entity;
use App\Repository\DestinationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass=DestinationRepository::class)
*/
class Destination
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* Slug immuable et unique (ex: "st-lucie")
* @Gedmo\Slug(fields={"name"}, updatable=true, unique=true)
* @ORM\Column(type="string", length=180, unique=true)
*/
private $slug;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $img;
/**
* @ORM\OneToMany(targetEntity=Hebergement::class, mappedBy="country")
*/
private $hebergements;
/**
* @ORM\OneToMany(targetEntity=Offer::class, mappedBy="destination")
*/
private $offers;
public function __construct()
{
$this->hebergements = new ArrayCollection();
$this->offers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* Get the value of name
*/
public function getName()
{
return $this->name;
}
/**
* Set the value of name
*
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getImg(): ?string
{
return $this->img;
}
public function setImg(?string $img): self
{
$this->img = $img;
return $this;
}
/**
* @return Collection<int, Hebergement>
*/
public function getHebergements(): Collection
{
return $this->hebergements;
}
public function addHebergement(Hebergement $hebergement): self
{
if (!$this->hebergements->contains($hebergement)) {
$this->hebergements[] = $hebergement;
$hebergement->setCountry($this);
}
return $this;
}
public function removeHebergement(Hebergement $hebergement): self
{
if ($this->hebergements->removeElement($hebergement)) {
// set the owning side to null (unless already changed)
if ($hebergement->getCountry() === $this) {
$hebergement->setCountry(null);
}
}
return $this;
}
/**
* @return Collection<int, Offer>
*/
public function getOffers(): Collection
{
return $this->offers;
}
public function addOffer(Offer $offer): self
{
if (!$this->offers->contains($offer)) {
$this->offers[] = $offer;
$offer->setDestination($this);
}
return $this;
}
public function removeOffer(Offer $offer): self
{
if ($this->offers->removeElement($offer)) {
// set the owning side to null (unless already changed)
if ($offer->getDestination() === $this) {
$offer->setDestination(null);
}
}
return $this;
}
/**
* Get slug immuable et unique (ex: "st-lucie")
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set slug immuable et unique (ex: "st-lucie")
*
* @return self
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
}