Add rider session entity #119

This commit is contained in:
Kendrick Chan 2018-05-22 20:59:13 +08:00
parent 93b41f7a1a
commit 87c6ca1926

109
src/Entity/RiderSession.php Normal file
View file

@ -0,0 +1,109 @@
<?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 = false;
}
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;
}
}