src/Entity/HotelChain.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\HotelChainRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassHotelChainRepository::class)]
  8. class HotelChain extends Provider
  9. {
  10.     #[ORM\OneToMany(mappedBy'chain'targetEntityHotel::class)]
  11.     private $hotels;
  12.     public function __construct()
  13.     {
  14.         parent::__construct();
  15.         $this->hotels = new ArrayCollection();
  16.     }
  17.     /**
  18.      * @return Collection<int, Hotel>
  19.      */
  20.     public function getHotels(): Collection
  21.     {
  22.         return $this->hotels;
  23.     }
  24.     public function addHotel(Hotel $hotel): self
  25.     {
  26.         if (!$this->hotels->contains($hotel)) {
  27.             $this->hotels[] = $hotel;
  28.             $hotel->setChain($this);
  29.         }
  30.         return $this;
  31.     }
  32.     public function removeHotel(Hotel $hotel): self
  33.     {
  34.         if ($this->hotels->removeElement($hotel)) {
  35.             // set the owning side to null (unless already changed)
  36.             if ($hotel->getChain() === $this) {
  37.                 $hotel->setChain(null);
  38.             }
  39.         }
  40.         return $this;
  41.     }
  42. }