<?php
namespace App\Entity;
use App\Repository\HotelChainRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: HotelChainRepository::class)]
class HotelChain extends Provider
{
#[ORM\OneToMany(mappedBy: 'chain', targetEntity: Hotel::class)]
private $hotels;
public function __construct()
{
parent::__construct();
$this->hotels = new ArrayCollection();
}
/**
* @return Collection<int, Hotel>
*/
public function getHotels(): Collection
{
return $this->hotels;
}
public function addHotel(Hotel $hotel): self
{
if (!$this->hotels->contains($hotel)) {
$this->hotels[] = $hotel;
$hotel->setChain($this);
}
return $this;
}
public function removeHotel(Hotel $hotel): self
{
if ($this->hotels->removeElement($hotel)) {
// set the owning side to null (unless already changed)
if ($hotel->getChain() === $this) {
$hotel->setChain(null);
}
}
return $this;
}
}