117 lines
2.1 KiB
PHP
117 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use DateTime;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="rider_session")
|
|
*/
|
|
class RiderSession
|
|
{
|
|
// unique id
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="string", length=13)
|
|
*/
|
|
protected $id;
|
|
|
|
// device id or push id used by device
|
|
/**
|
|
* @ORM\Column(type="string", length=50)
|
|
*/
|
|
protected $device_push_id;
|
|
|
|
// link to customer
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Rider", inversedBy="sessions")
|
|
* @ORM\JoinColumn(name="rider_id", referencedColumnName="id", nullable=true)
|
|
*/
|
|
protected $rider;
|
|
|
|
// phone number
|
|
/**
|
|
* @ORM\Column(type="string", length=12, nullable=true)
|
|
*/
|
|
protected $phone_number;
|
|
|
|
// is this device active
|
|
/**
|
|
* @ORM\Column(type="boolean")
|
|
*/
|
|
protected $is_active;
|
|
|
|
|
|
public function __construct()
|
|
{
|
|
// default date generated to now
|
|
$this->id = $this->generateKeyID();
|
|
$this->rider = null;
|
|
$this->is_active = true;
|
|
}
|
|
|
|
public function generateKeyID()
|
|
{
|
|
// use uniqid for now, since primary key dupes will trigger exceptions
|
|
return uniqid();
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setDevicePushID($id)
|
|
{
|
|
$this->device_push_id = $id;
|
|
return $this;
|
|
}
|
|
|
|
public function getDevicePushID()
|
|
{
|
|
return $this->device_push_id;
|
|
}
|
|
|
|
public function setRider(Rider $rider = null)
|
|
{
|
|
$this->rider = $rider;
|
|
return $this;
|
|
}
|
|
|
|
public function getRider()
|
|
{
|
|
return $this->rider;
|
|
}
|
|
|
|
public function setPhoneNumber($num)
|
|
{
|
|
$this->phone_number = $num;
|
|
return $this;
|
|
}
|
|
|
|
public function getPhoneNumber()
|
|
{
|
|
return $this->phone_number;
|
|
}
|
|
|
|
public function setActive($flag = true)
|
|
{
|
|
$this->is_active = $flag;
|
|
return $this;
|
|
}
|
|
|
|
public function isActive()
|
|
{
|
|
return $this->is_active;
|
|
}
|
|
|
|
public function hasRider()
|
|
{
|
|
if ($this->rider == null)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
}
|