<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\TrackingRepository")
*/
class Tracking
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $token;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="trackings")
*/
private $user;
/**
* @ORM\Column(type="string", length=255)
*/
private $user_agent;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $logged_at;
/**
* @ORM\OneToMany(targetEntity="App\Entity\TrackingDetail", mappedBy="tracking", orphanRemoval=true)
*/
private $trackingDetails;
public function __construct()
{
$this->created_at=new \DateTime();
$this->trackingDetails = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(string $token): self
{
$this->token = $token;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getUserAgent(): ?string
{
return $this->user_agent;
}
public function setUserAgent(string $user_agent): self
{
$this->user_agent = $user_agent;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getLoggedAt(): ?\DateTimeInterface
{
return $this->logged_at;
}
public function setLoggedAt(?\DateTimeInterface $logged_at): self
{
$this->logged_at = $logged_at;
return $this;
}
/**
* @return Collection|TrackingDetail[]
*/
public function getTrackingDetails(): Collection
{
return $this->trackingDetails;
}
public function addTrackingDetail(TrackingDetail $trackingDetail): self
{
if (!$this->trackingDetails->contains($trackingDetail)) {
$this->trackingDetails[] = $trackingDetail;
$trackingDetail->setTracking($this);
}
return $this;
}
public function removeTrackingDetail(TrackingDetail $trackingDetail): self
{
if ($this->trackingDetails->contains($trackingDetail)) {
$this->trackingDetails->removeElement($trackingDetail);
// set the owning side to null (unless already changed)
if ($trackingDetail->getTracking() === $this) {
$trackingDetail->setTracking(null);
}
}
return $this;
}
}