src/Entity/Accounts/Favorites.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Accounts;
  3. use App\Entity\Otpusk\Hotel;
  4. use App\Repository\Accounts\FavoritesRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\Accounts\FavoritesRepository")
  10.  * @ORM\Table(name="otp_accounts.tFavorites", indexes={@ORM\Index(name="fAdded", columns={"fAdded"})})
  11.  */
  12. class Favorites
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\Column(name="rec_id", type="integer", options={"unsigned"=true})
  17.      * @ORM\GeneratedValue(strategy="AUTO")
  18.      */
  19.     private int $id;
  20.     /**
  21.      * @ORM\OneToMany(targetEntity="UserFavorite", mappedBy="favorite", cascade={"persist", "remove"})
  22.      */
  23.     private Collection $userFavorites;
  24.     public function __construct()
  25.     {
  26.         $this->userFavorites = new ArrayCollection();
  27.     }
  28.     public function getUserFavorites(): Collection
  29.     {
  30.         return $this->userFavorites;
  31.     }
  32.     public function addUserFavorite(UserFavorite $userFavorite): self
  33.     {
  34.         if (!$this->userFavorites->contains($userFavorite)) {
  35.             $this->userFavorites[] = $userFavorite;
  36.             $userFavorite->setFavorite($this);
  37.         }
  38.         return $this;
  39.     }
  40.     public function removeUserFavorite(UserFavorite $userFavorite): self
  41.     {
  42.         if ($this->userFavorites->removeElement($userFavorite)) {
  43.             if ($userFavorite->getFavorite() === $this) {
  44.                 $userFavorite->setFavorite(null);
  45.             }
  46.         }
  47.         return $this;
  48.     }
  49.     /**
  50.      * @ORM\Column(name="fGeoId", type="integer", nullable=true)
  51.      */
  52.     private ?int $hotelId null;
  53.     /**
  54.      * @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Hotel", inversedBy="favorites", fetch="EAGER")
  55.      * @ORM\JoinColumn(name="fGeoId", referencedColumnName="rec_id", nullable=true)
  56.      */
  57.     private ?Hotel $hotel null;
  58.     public function getHotel(): ?Hotel
  59.     {
  60.         return $this->hotel;
  61.     }
  62.     public function setHotel(?Hotel $hotel): self
  63.     {
  64.         $this->hotel $hotel;
  65.         return $this;
  66.     }
  67.     /**
  68.      * @ORM\Column(name="fOfferId", type="string", length=64, nullable=true)
  69.      */
  70.     private ?string $offerId null;
  71.     /**
  72.      * @ORM\Column(name="fQuery", type="string", length=255, nullable=true)
  73.      */
  74.     private ?string $query null;
  75.     /**
  76.      * @ORM\Column(name="fAdded", type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  77.      */
  78.     private \DateTime $createdAt;
  79.     public function getId(): int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getHotelId(): ?int
  84.     {
  85.         return $this->hotelId;
  86.     }
  87.     public function setHotelId(?int $hotelId): self
  88.     {
  89.         $this->hotelId $hotelId;
  90.         return $this;
  91.     }
  92.     public function getOfferId(): ?string
  93.     {
  94.         return $this->offerId;
  95.     }
  96.     public function setOfferId(?string $offerId): self
  97.     {
  98.         $this->offerId $offerId;
  99.         return $this;
  100.     }
  101.     public function getQuery(): ?string
  102.     {
  103.         return $this->query;
  104.     }
  105.     public function setQuery(?string $query): self
  106.     {
  107.         $this->query $query;
  108.         return $this;
  109.     }
  110.     public function getCreatedAt(): \DateTime
  111.     {
  112.         return $this->createdAt;
  113.     }
  114.     public function setCreatedAt(\DateTime $createdAt): self
  115.     {
  116.         $this->createdAt $createdAt;
  117.         return $this;
  118.     }
  119. }