|
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use App\Entity\OrderShop;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class Visitor
- {
- /**
- * @ORM\Column(type="string", length=255)
- */
- protected $cookie;
-
- /**
- * @ORM\Column(type="datetime")
- */
- protected $lastAccess;
-
- /**
- * @ORM\Column(type="string", length=255)
- */
- protected $ip;
-
- /**
- * @ORM\Column(type="integer")
- */
- protected $totalVisit;
-
- /**
- * @ORM\OneToMany(targetEntity="App\Entity\OrderShop", mappedBy="visitor")
- */
- protected $orders;
-
- public function __construct()
- {
- $this->orders = new ArrayCollection();
- }
-
- public function __toString()
- {
- return $this->getLastAccess()->format('d-m-y h:i') .'( visites :'.$this->totalVisit.')';
- }
- public function getSummary(){
- return 'Visiteur non inscrit ( visites :'.$this->totalVisit.')';
- }
-
- public function getCookie(): ?string
- {
- return $this->cookie;
- }
-
- public function setCookie(?string $cookie): self
- {
- $this->cookie = $cookie;
-
- return $this;
- }
-
- public function getLastAccess(): ?\DateTimeInterface
- {
- return $this->lastAccess;
- }
-
- public function setLastAccess(\DateTimeInterface $lastAccess): self
- {
- $this->lastAccess = $lastAccess;
-
- return $this;
- }
-
- public function getIp(): ?string
- {
- return $this->ip;
- }
-
- public function setIp(?string $ip): self
- {
- $this->ip = $ip;
-
- return $this;
- }
-
- public function getTotalVisit(): ?int
- {
- return $this->totalVisit;
- }
-
- public function setTotalVisit(int $totalVisit): self
- {
- $this->totalVisit = $totalVisit;
-
- return $this;
- }
-
- /**
- * @return Collection|OrderShop[]
- */
- public function getOrders(): Collection
- {
- return $this->orders;
- }
-
- public function addOrder(OrderShop $order): self
- {
- if (!$this->orders->contains($order)) {
- $this->orders[] = $order;
- $order->setVisitor($this);
- }
-
- return $this;
- }
-
- public function removeOrder(OrderShop $order): self
- {
- if ($this->orders->contains($order)) {
- $this->orders->removeElement($order);
- // set the owning side to null (unless already changed)
- if ($order->getVisitor() === $this) {
- $order->setVisitor(null);
- }
- }
-
- return $this;
- }
- }
|