<?php
namespace App\AppBundle\AdminBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use JsonSerializable;
/**
* AddOns
*
* @ORM\Entity
* @ORM\Table(name="admin_token")
* @ORM\HasLifecycleCallbacks()
*/
class Admin_Token implements JsonSerializable
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* Many Token have one user. This is the owning side.
* @ORM\ManyToOne(targetEntity="Admin_User", inversedBy="admin_tokens")
* @ORM\JoinColumn(name="admin_user_id", referencedColumnName="id")
*/
private $admin_user;
/**
* @ORM\Column(type="string", nullable=false)
* @Assert\NotBlank()
*/
private $token;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank()
*/
private $ip_address;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank()
*/
private $device_name;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank()
*/
private $device_os_version;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getAdminUser()
{
return $this->admin_user;
}
/**
* @param mixed $admin_user
*/
public function setAdminUser($admin_user)
{
$this->admin_user = $admin_user;
}
/**
* @return mixed
*/
public function getToken()
{
return $this->token;
}
/**
* @param mixed $token
*/
public function setToken($token)
{
$this->token = $token;
}
/**
* @return mixed
*/
public function getIpAddress()
{
return $this->ip_address;
}
/**
* @param mixed $ip_address
*/
public function setIpAddress($ip_address)
{
$this->ip_address = $ip_address;
}
/**
* @return mixed
*/
public function getDeviceName()
{
return $this->device_name;
}
/**
* @param mixed $device_name
*/
public function setDeviceName($device_name)
{
$this->device_name = $device_name;
}
/**
* @return mixed
*/
public function getDeviceOsVersion()
{
return $this->device_os_version;
}
/**
* @param mixed $device_os_version
*/
public function setDeviceOsVersion($device_os_version)
{
$this->device_os_version = $device_os_version;
}
/**
* @var string $created
*
* @ORM\Column(name="created_at", type="string", nullable=false)
*/
protected $createdAt;
/**
* @var string $updated
*
* @ORM\Column(name="updated_at", type="string", nullable=false)
*/
protected $updatedAt;
public function getCreatedAt()
{
return $this->createdAt;
}
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps()
{
$this->setUpdatedAt(round(microtime(true) * 1000));
if ($this->getCreatedAt() === null) {
$this->setCreatedAt(round(microtime(true) * 1000));
}
}
public function __construct() {
$this->setCreatedAt(round(microtime(true) * 1000));
}
public function jsonSerialize()
{
return array(
'id' => $this->id
);
}
}