<?php
namespace App\Entity\Accounts;
use App\Entity\Otpusk\Hotel;
use App\Repository\Accounts\FavoritesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\Accounts\FavoritesRepository")
* @ORM\Table(name="otp_accounts.tFavorites", indexes={@ORM\Index(name="fAdded", columns={"fAdded"})})
*/
class Favorites
{
/**
* @ORM\Id
* @ORM\Column(name="rec_id", type="integer", options={"unsigned"=true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
private int $id;
/**
* @ORM\OneToMany(targetEntity="UserFavorite", mappedBy="favorite", cascade={"persist", "remove"})
*/
private Collection $userFavorites;
public function __construct()
{
$this->userFavorites = new ArrayCollection();
}
public function getUserFavorites(): Collection
{
return $this->userFavorites;
}
public function addUserFavorite(UserFavorite $userFavorite): self
{
if (!$this->userFavorites->contains($userFavorite)) {
$this->userFavorites[] = $userFavorite;
$userFavorite->setFavorite($this);
}
return $this;
}
public function removeUserFavorite(UserFavorite $userFavorite): self
{
if ($this->userFavorites->removeElement($userFavorite)) {
if ($userFavorite->getFavorite() === $this) {
$userFavorite->setFavorite(null);
}
}
return $this;
}
/**
* @ORM\Column(name="fGeoId", type="integer", nullable=true)
*/
private ?int $hotelId = null;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Hotel", inversedBy="favorites", fetch="EAGER")
* @ORM\JoinColumn(name="fGeoId", referencedColumnName="rec_id", nullable=true)
*/
private ?Hotel $hotel = null;
public function getHotel(): ?Hotel
{
return $this->hotel;
}
public function setHotel(?Hotel $hotel): self
{
$this->hotel = $hotel;
return $this;
}
/**
* @ORM\Column(name="fOfferId", type="string", length=64, nullable=true)
*/
private ?string $offerId = null;
/**
* @ORM\Column(name="fQuery", type="string", length=255, nullable=true)
*/
private ?string $query = null;
/**
* @ORM\Column(name="fAdded", type="datetime", options={"default": "CURRENT_TIMESTAMP"})
*/
private \DateTime $createdAt;
public function getId(): int
{
return $this->id;
}
public function getHotelId(): ?int
{
return $this->hotelId;
}
public function setHotelId(?int $hotelId): self
{
$this->hotelId = $hotelId;
return $this;
}
public function getOfferId(): ?string
{
return $this->offerId;
}
public function setOfferId(?string $offerId): self
{
$this->offerId = $offerId;
return $this;
}
public function getQuery(): ?string
{
return $this->query;
}
public function setQuery(?string $query): self
{
$this->query = $query;
return $this;
}
public function getCreatedAt(): \DateTime
{
return $this->createdAt;
}
public function setCreatedAt(\DateTime $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
}