Your IP : 216.73.217.79


Current Path : /var/www/v3.cesa.co.za/src/SessionsBundle/Entity/
Upload File :
Current File : /var/www/v3.cesa.co.za/src/SessionsBundle/Entity/Sessions.php

<?php

namespace App\SessionsBundle\Entity;

use App\ShoppingCartBundle\Entity\Baskets;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/**
 * Sessions
 *
 * @ORM\Table(name="sessions", indexes={
 *     @ORM\Index(name="index_symfony_cookie", columns={"symfony_cookie"}),
 *     @ORM\Index(name="index_cookie_name", columns={"cookie_name"}),
 *     @ORM\Index(name="index_remote_ip", columns={"remote_ip"}),
 *     @ORM\Index(name="index_created_at", columns={"created_at"}),
 *     @ORM\Index(name="index_updated_at", columns={"updated_at"})
 * })
 * @ORM\Entity(repositoryClass="App\SessionsBundle\Repository\SessionsRepository")
 * @ORM\HasLifecycleCallbacks
 */
class Sessions
{

    /**
     * @ORM\Id
     * @ORM\Column(type="string", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
     */
    private ?string $id = null;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private ?string $symfony_cookie = null;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private ?string $cookie_name = null;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private ?string $remote_ip = null;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private ?string $remote_domain = null;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private ?string $browser_string = null;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private ?string $created_by = null;

    /**
     * @ORM\Column(type="datetime")
     */
    private ?\DateTimeInterface $created_at = null;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private ?\DateTimeInterface $updated_at = null;

    /**
     * @ORM\OneToMany(targetEntity="SessionUrls", mappedBy="sessions", cascade={"persist", "remove"})
     */
    private Collection $session_urls;

    /**
     * @ORM\OneToMany(targetEntity="SessionValues", mappedBy="sessions", cascade={"persist", "remove"})
     */
    private Collection $session_values;

    /**
     * @ORM\OneToMany(targetEntity="SessionTextValues", mappedBy="sessions", cascade={"persist", "remove"})
     */
    private Collection $session_text_values;

    /**
     * @ORM\ManyToOne(targetEntity="Sites", inversedBy="sessions", cascade={"persist", "remove"})
     * @ORM\JoinColumn(name="site_id", referencedColumnName="id")
     */
    private ?Sites $sites = null;

    /**
     * @ORM\ManyToOne(targetEntity="Sessions", cascade={"persist", "remove"})
     * @ORM\JoinColumn(name="previous_session_id", referencedColumnName="id")
     */
    private ?self $previous_session = null;

    public function __construct()
    {
        $this->session_urls = new ArrayCollection();
        $this->session_values = new ArrayCollection();
        $this->session_text_values = new ArrayCollection();
    }

    /**
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        if (!$this->getCreatedAt()) {
            $this->created_at = new \DateTime();
        }
        $this->updated_at = new \DateTime();
    }

    /**
     * @ORM\PreUpdate
     */
    public function setUpdatedAtValue()
    {
        $this->updated_at = new \DateTime();
    }

    public function getId(): ?string
    {
        return $this->id;
    }

    public function getSymfonyCookie(): ?string
    {
        return $this->symfony_cookie;
    }

    public function setSymfonyCookie(string $symfony_cookie): static
    {
        $this->symfony_cookie = $symfony_cookie;

        return $this;
    }

    public function getCookieName(): ?string
    {
        return $this->cookie_name;
    }

    public function setCookieName(?string $cookie_name): static
    {
        $this->cookie_name = $cookie_name;

        return $this;
    }

    public function getRemoteIp(): ?string
    {
        return $this->remote_ip;
    }

    public function setRemoteIp(?string $remote_ip): static
    {
        $this->remote_ip = $remote_ip;

        return $this;
    }

    public function getRemoteDomain(): ?string
    {
        return $this->remote_domain;
    }

    public function setRemoteDomain(?string $remote_domain): static
    {
        $this->remote_domain = $remote_domain;

        return $this;
    }

    public function getBrowserString(): ?string
    {
        return $this->browser_string;
    }

    public function setBrowserString(string $browser_string): static
    {
        $this->browser_string = $browser_string;

        return $this;
    }

    public function getCreatedBy(): ?string
    {
        return $this->created_by;
    }

    public function setCreatedBy(?string $created_by): static
    {
        $this->created_by = $created_by;

        return $this;
    }

    public function getCreatedAt(): ?\DateTimeInterface
    {
        return $this->created_at;
    }

    public function setCreatedAt(\DateTimeInterface $created_at): static
    {
        $this->created_at = $created_at;

        return $this;
    }

    public function getUpdatedAt(): ?\DateTimeInterface
    {
        return $this->updated_at;
    }

    public function setUpdatedAt(?\DateTimeInterface $updated_at): static
    {
        $this->updated_at = $updated_at;

        return $this;
    }

    /**
     * @return Collection<int, SessionUrls>
     */
    public function getSessionUrls(): Collection
    {
        return $this->session_urls;
    }

    public function addSessionUrl(SessionUrls $sessionUrl): static
    {
        if (!$this->session_urls->contains($sessionUrl)) {
            $this->session_urls->add($sessionUrl);
            $sessionUrl->setSessions($this);
        }

        return $this;
    }

    public function removeSessionUrl(SessionUrls $sessionUrl): static
    {
        if ($this->session_urls->removeElement($sessionUrl)) {
            // set the owning side to null (unless already changed)
            if ($sessionUrl->getSessions() === $this) {
                $sessionUrl->setSessions(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, SessionValues>
     */
    public function getSessionValues(): Collection
    {
        return $this->session_values;
    }

    public function addSessionValue(SessionValues $sessionValue): static
    {
        if (!$this->session_values->contains($sessionValue)) {
            $this->session_values->add($sessionValue);
            $sessionValue->setSessions($this);
        }

        return $this;
    }

    public function removeSessionValue(SessionValues $sessionValue): static
    {
        if ($this->session_values->removeElement($sessionValue)) {
            // set the owning side to null (unless already changed)
            if ($sessionValue->getSessions() === $this) {
                $sessionValue->setSessions(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection<int, SessionTextValues>
     */
    public function getSessionTextValues(): Collection
    {
        return $this->session_text_values;
    }

    public function addSessionTextValue(SessionTextValues $sessionTextValue): static
    {
        if (!$this->session_text_values->contains($sessionTextValue)) {
            $this->session_text_values->add($sessionTextValue);
            $sessionTextValue->setSessions($this);
        }

        return $this;
    }

    public function removeSessionTextValue(SessionTextValues $sessionTextValue): static
    {
        if ($this->session_text_values->removeElement($sessionTextValue)) {
            // set the owning side to null (unless already changed)
            if ($sessionTextValue->getSessions() === $this) {
                $sessionTextValue->setSessions(null);
            }
        }

        return $this;
    }

    public function getSites(): ?Sites
    {
        return $this->sites;
    }

    public function setSites(?Sites $sites): static
    {
        $this->sites = $sites;

        return $this;
    }

    public function getPreviousSession(): ?self
    {
        return $this->previous_session;
    }

    public function setPreviousSession(?self $previous_session): static
    {
        $this->previous_session = $previous_session;

        return $this;
    }

    public function previousSessionCheck()
    {
        if (is_object($this->getPreviousSession()))
            return true;
        else
            return false;
    }
}