From db0a53fd1e98c1f06670fe70a73e3db0184eccf0 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Sun, 28 Jan 2018 05:17:25 +0800 Subject: [PATCH] Adjust mobile session entity --- src/Entity/MobileSession.php | 171 ++++++++++++++++++++++++++++++++++- 1 file changed, 168 insertions(+), 3 deletions(-) diff --git a/src/Entity/MobileSession.php b/src/Entity/MobileSession.php index 21872771..25d6df8b 100644 --- a/src/Entity/MobileSession.php +++ b/src/Entity/MobileSession.php @@ -14,29 +14,194 @@ class MobileSession // unique id /** * @ORM\Id - * @ORM\Column(type="string", length=10) + * @ORM\Column(type="string", length=13) */ protected $id; + // phone model + /** + *@ORM\Column(type="string", length=50) + */ + protected $phone_model; + + // operating system (android, ios, etc) + /** + *@ORM\Column(type="string", length=15) + */ + protected $os_type; + + // os version + /** + *@ORM\Column(type="string", length=25) + */ + protected $os_version; + + // device id or push id used by device + /** + *@ORM\Column(type="string", length=50) + */ + protected $device_push_id; + // link to customer /** * @ORM\ManyToOne(targetEntity="Customer", inversedBy="sessions") - * @ORM\JoinColumn(name="customer_id", referencedColumnName="id") + * @ORM\JoinColumn(name="customer_id", referencedColumnName="id", nullable=true) */ protected $customer; + // phone number + /** + *@ORM\Column(type="string", length=12) + */ + protected $phone_number; + + // confirm code that we send via SMS + /** + *@ORM\Column(type="string", length=6) + */ + protected $confirm_code; + + // is confirmed? + /** + *@ORM\Column(type="boolean") + */ + protected $confirm_flag; + // date the session id was generated and sent to mobile app /** * @ORM\Column(type="datetime") */ protected $date_generated; + // date the phone number was confirmed + /** + * @ORM\Column(type="datetime", nullable=true) + */ + protected $date_confirmed; - // TODO: get the details we can recover from the phone public function __construct() { // default date generated to now + $this->id = $this->generateKeyID(); $this->date_generated = new DateTime(); + $this->customer = null; + $this->confirm_flag = false; + $this->date_confirmed = null; + } + + public function generateKeyID() + { + // use uniqid for now, since primary key dupes will trigger exceptions + return uniqid(); + } + + public function getID() + { + return $this->id; + } + + public function setPhoneModel($model) + { + $this->phone_model = $model; + return $this; + } + + public function getPhoneModel() + { + return $this->phone_model; + } + + public function setOSType($type) + { + $this->os_type = $type; + return $this; + } + + public function getOSType() + { + return $this->os_type; + } + + public function setOSVersion($version) + { + $this->os_version = $version; + return $this; + } + + public function getOSVersion() + { + return $this->os_version; + } + + public function setDevicePushID($id) + { + $this->device_push_id = $id; + return $this; + } + + public function getDevicePushID() + { + return $this->device_push_id; + } + + public function setCustomer(Customer $cust = null) + { + $this->customer = $cust; + return $this; + } + + public function getCustomer() + { + return $this->customer; + } + + public function getDateGenerated() + { + return $this->date_generated; + } + + public function setPhoneNumber($num) + { + $this->phone_number = $num; + return $this; + } + + public function getPhoneNumber() + { + return $this->phone_number; + } + + public function setConfirmCode($code) + { + $this->confirm_code = $code; + return $this; + } + + public function getConfirmCode() + { + return $this->confirm_code; + } + + public function setConfirmed($flag = true) + { + $this->confirm_flag = $flag; + return $this; + } + + public function isConfirmed() + { + return $this->confirm_flag; + } + + public function setDateConfirm(DateTime $date) + { + $this->date_confirmed = $date; + return $this; + } + + public function getDateConfirm() + { + return $this->date_confirmed; } }