resq/src/Entity/MobileSession.php

257 lines
5 KiB
PHP

<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use DateTime;
/**
* @ORM\Entity
* @ORM\Table(name="mobile_session")
*/
class MobileSession
{
// unique id
/**
* @ORM\Id
* @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=200, nullable=true)
*/
protected $device_push_id;
// phone id
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
protected $phone_id;
// link to customer
/**
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="sessions")
* @ORM\JoinColumn(name="customer_id", referencedColumnName="id", nullable=true)
*/
protected $customer;
// phone number
/**
* @ORM\Column(type="string", length=12, nullable=true)
*/
protected $phone_number;
// confirm code that we send via SMS
/**
* @ORM\Column(type="string", length=6, nullable=true)
*/
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;
// date and time that the confirmation code was last sent
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $date_code_sent;
// reviews made by mobile session
/**
* @ORM\OneToMany(targetEntity="Review", mappedBy="mobile_session")
*/
protected $reviews;
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;
$this->date_code_sent = null;
$this->reviews = new ArrayCollection();
}
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 setPhoneID($id)
{
$this->phone_id = $id;
return $this;
}
public function getPhoneID()
{
return $this->phone_id;
}
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 setDateConfirmed(DateTime $date)
{
$this->date_confirmed = $date;
return $this;
}
public function getDateConfirmed()
{
return $this->date_confirmed;
}
public function setDateCodeSent(DateTime $date)
{
$this->date_code_sent = $date;
return $this;
}
public function getDateCodeSent()
{
return $this->date_code_sent;
}
public function getReviews()
{
return $this->reviews;
}
}