src/Entity/UserStats.php line 17
- <?php
- namespace App\Entity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use App\Entity\Reserva;
- use App\Entity\Transaccion;
- use Doctrine\ORM\Mapping as ORM;
- use JMS\Serializer\Annotation as JMS;
- /**
- *
- * @ORM\Table(name="user_stats")
- * @ORM\Entity(repositoryClass="App\Repository\UserStatsRepository")
- */
- class UserStats
- {
- /**
- * @ORM\Id
- * @ORM\Column(type="integer")
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @var string
- * @ORM\Column(name="session_id", type="string")
- */
- protected $sessionId;
- /**
- * @var User
- * @ORM\ManyToOne(targetEntity="User")
- * @ORM\JoinColumn(name="user", nullable=true)
- */
- protected $user;
- /**
- * @var string
- * @ORM\Column(name="uuid", type="string", nullable=true)
- * @JMS\Groups({"api-stats"})
- */
- protected $uuid;
- /**
- * @var \DateTime
- * @ORM\Column(name="session_start", type="datetime")
- * @JMS\Groups({"api-stats"})
- */
- protected $sessionStart;
- /**
- * @var \DateTime
- * @ORM\Column(name="last_update", type="datetime")
- * @JMS\Groups({"api-stats"})
- */
- protected $lastUpdate;
- /**
- * @var string[]
- * @ORM\Column(name="visited_pages", type="json", nullable=true)
- * @JMS\Groups({"api-stats"})
- */
- protected $visitedPages;
- /**
- * @var string
- * @ORM\Column(name="referer", type="string", nullable=true)
- * @JMS\Groups({"api-stats"})
- */
- protected $referer;
- /**
- * @var string
- * @ORM\Column(name="ip" ,type="string")
- * @JMS\Groups({"api-stats"})
- */
- protected $ip;
- /**
- * @var Collection|Reserva[]
- * @ORM\ManyToMany(targetEntity="Reserva", inversedBy="userStats")
- * @ORM\JoinTable(name="user__stats_booking")
- */
- protected $bookingConversions;
- /**
- * @var Collection|Transaccion[]
- * @ORM\ManyToMany(targetEntity="Transaccion", inversedBy="userStats")
- * @ORM\JoinTable(name="user__stats_order")
- */
- protected $orderConversions;
- /**
- * @var string
- * @ORM\Column(name="device", type="string", nullable=true)
- * @JMS\Groups({"api-stats"})
- */
- protected $device;
- /**
- * @var string
- * @ORM\Column(name="country", type="string", nullable=true)
- * @JMS\Groups({"api-stats"})
- */
- protected $country;
- /**
- * @var string
- * @ORM\Column(name="region", type="string", nullable=true)
- * @JMS\Groups({"api-stats"})
- */
- protected $region;
- /**
- * @var string
- * @ORM\Column(name="city", type="string", nullable=true)
- * @JMS\Groups({"api-stats"})
- */
- protected $city;
- /**
- * @var string
- * @ORM\Column(name="zip", type="string", nullable=true)
- * @JMS\Groups({"api-stats"})
- */
- protected $zip;
- /**
- * @var string
- * @ORM\Column(name="locale", type="string", nullable=true)
- * @JMS\Groups({"api-stats"})
- */
- protected $locale;
- /**
- * Constructor
- */
- public function __construct()
- {
- $this->bookingConversions = new ArrayCollection();
- $this->orderConversions = new ArrayCollection();
- $this->sessionStart = new \DateTime();
- $this->visitedPages = [];
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set sessionId
- *
- * @param string $sessionId
- *
- * @return UserStats
- */
- public function setSessionId($sessionId)
- {
- $this->sessionId = $sessionId;
- return $this;
- }
- /**
- * Get sessionId
- *
- * @return string
- */
- public function getSessionId()
- {
- return $this->sessionId;
- }
- /**
- * Set sessionStart
- *
- * @param \DateTime $sessionStart
- *
- * @return UserStats
- */
- public function setSessionStart($sessionStart)
- {
- $this->sessionStart = $sessionStart;
- return $this;
- }
- /**
- * Get sessionStart
- *
- * @return \DateTime
- */
- public function getSessionStart()
- {
- return $this->sessionStart;
- }
- /**
- * Set lastUpdate
- *
- * @param \DateTime $lastUpdate
- *
- * @return UserStats
- */
- public function setLastUpdate($lastUpdate)
- {
- $this->lastUpdate = $lastUpdate;
- return $this;
- }
- /**
- * Get lastUpdate
- *
- * @return \DateTime
- */
- public function getLastUpdate()
- {
- return $this->lastUpdate;
- }
- /**
- * Set visitedPages
- *
- * @param array $visitedPages
- *
- * @return UserStats
- */
- public function setVisitedPages($visitedPages)
- {
- $this->visitedPages = $visitedPages;
- return $this;
- }
- /**
- * Get visitedPages
- *
- * @return array
- */
- public function getVisitedPages()
- {
- return $this->visitedPages;
- }
- /**
- * @param string $visitedPage
- * @return $this
- */
- public function addVisitedPage($visitedPage)
- {
- foreach ($this->visitedPages as $page)
- {
- if($visitedPage==$page) return $this;
- }
- $this->visitedPages[]=$visitedPage;
- return $this;
- }
- /**
- * @param $visitedPage
- * @return $this
- */
- public function removeVisitedPage($visitedPage)
- {
- foreach ($this->visitedPages as $key=>$page)
- {
- if($visitedPage==$page) unset($this->visitedPages[$key]);
- }
- return $this;
- }
- public function getVisitedPagesAsString()
- {
- $pages = implode(',', $this->visitedPages);
- if (strlen($pages) > 30)
- $pages = substr(implode(',', $this->visitedPages), 0, 30)."...";
- return $pages;
- }
- /**
- * @param string $referer
- *
- * @return UserStats
- */
- public function setReferer($referer)
- {
- $this->referer = $referer;
- return $this;
- }
- /**
- * Get referer
- *
- * @return string
- */
- public function getReferer()
- {
- return $this->referer;
- }
- /**
- * Set ip
- *
- * @param string $ip
- *
- * @return UserStats
- */
- public function setIp($ip)
- {
- $this->ip = $ip;
- return $this;
- }
- /**
- * Get ip
- *
- * @return string
- */
- public function getIp()
- {
- return $this->ip;
- }
- /**
- * Set device
- *
- * @param string $device
- *
- * @return UserStats
- */
- public function setDevice($device)
- {
- $this->device = $device;
- return $this;
- }
- /**
- * Get device
- *
- * @return string
- */
- public function getDevice()
- {
- return $this->device;
- }
- /**
- * Set user
- *
- * @param User $user
- *
- * @return UserStats
- */
- public function setUser(User $user = null)
- {
- $this->user = $user;
- return $this;
- }
- /**
- * Get user
- *
- * @return User
- */
- public function getUser()
- {
- return $this->user;
- }
- /**
- * @param string $uuid
- */
- public function setUuid($uuid)
- {
- $this->uuid = $uuid;
- }
- /**
- * @return string
- */
- public function getUuid()
- {
- return $this->uuid;
- }
- /**
- * Add bookingConversion
- *
- * @param Reserva $bookingConversion
- *
- * @return UserStats
- */
- public function addBookingConversion(Reserva $bookingConversion)
- {
- $this->bookingConversions[] = $bookingConversion;
- return $this;
- }
- /**
- * Remove bookingConversion
- *
- * @param Reserva $bookingConversion
- */
- public function removeBookingConversion(Reserva $bookingConversion)
- {
- $this->bookingConversions->removeElement($bookingConversion);
- }
- /**
- * Get bookingConversion
- *
- * @return Collection
- */
- public function getBookingConversions()
- {
- return $this->bookingConversions;
- }
- /**
- * Add orderConversion
- *
- * @param Transaccion $orderConversion
- *
- * @return UserStats
- */
- public function addOrderConversion(Transaccion $orderConversion)
- {
- $this->orderConversions[] = $orderConversion;
- return $this;
- }
- /**
- * Remove orderConversion
- *
- * @param Transaccion $orderConversion
- */
- public function removeOrderConversion(Transaccion $orderConversion)
- {
- $this->orderConversions->removeElement($orderConversion);
- }
- /**
- * Get orderConversion
- *
- * @return Collection
- */
- public function getOrderConversions()
- {
- return $this->orderConversions;
- }
- /**
- * @param string $country
- */
- public function setCountry($country)
- {
- $this->country = $country;
- }
- /**
- * @return string
- */
- public function getCountry()
- {
- return $this->country;
- }
- /**
- * @param string $region
- */
- public function setRegion($region)
- {
- $this->region = $region;
- }
- /**
- * @return string
- */
- public function getRegion()
- {
- return $this->region;
- }
- /**
- * @param string $city
- */
- public function setCity($city)
- {
- $this->city = $city;
- }
- /**
- * @return string
- */
- public function getCity()
- {
- return $this->city;
- }
- /**
- * @param string $zip
- */
- public function setZip($zip)
- {
- $this->zip = $zip;
- }
- /**
- * @return string
- */
- public function getZip()
- {
- return $this->zip;
- }
- /**
- * @param array $location
- */
- public function setLocation(array $location)
- {
- if(isset($location['country']))
- {
- $this->country=$location['country'];
- }
- if(isset($location['regionName']))
- {
- $this->region=$location['regionName'];
- }
- if(isset($location['city']))
- {
- $this->city=$location['city'];
- }
- if(isset($location['zip']))
- {
- $this->zip=$location['zip'];
- }
- }
- /**
- * @param string $locale
- */
- public function setLocale($locale)
- {
- $this->locale = $locale;
- }
- /**
- * @return string
- */
- public function getLocale()
- {
- return $this->locale;
- }
- }