Add MobileUser entity. Add association between MobileUser and Customer. #591

This commit is contained in:
Korina Cordero 2021-06-23 08:24:49 +00:00
parent 642803217d
commit 2125f36e77
2 changed files with 293 additions and 0 deletions

View file

@ -215,6 +215,12 @@ class Customer
*/
protected $customer_tags;
// mobile users linked to this customer
/**
* @ORM\OneToMany(targetEntity="MobileUser", mappedBy="customer")
*/
protected $mobile_users;
public function __construct()
{
$this->numbers = new ArrayCollection();
@ -222,6 +228,7 @@ class Customer
$this->vehicles = new ArrayCollection();
$this->job_orders = new ArrayCollection();
$this->customer_tags = new ArrayCollection();
$this->mobile_users = new ArrayCollection();
$this->customer_classification = CustomerClassification::REGULAR;
$this->customer_notes = '';
@ -656,4 +663,22 @@ class Customer
$this->customer_tags->removeElement($customer_tag);
$customer_tag->removeCustomer($this);
}
public function addMobileUser(MobileUser $mobile_user)
{
$this->mobile_users->add($mobile_user);
return $this;
}
public function clearMobileUsers()
{
$this->mobile_users->clear();
return $this;
}
public function getMobileUsers()
{
return $this->mobile_users;
}
}

268
src/Entity/MobileUser.php Normal file
View file

@ -0,0 +1,268 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use DateTime;
/**
* @ORM\Entity
* @ORM\Table(name="mobile_user")
*/
class MobileUser
{
// 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;
// capi user id loosely associated to mobile user
/**
* @ORM\Column(type="integer", nullable=true)
*/
protected $capi_user_id;
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();
$this->capi_user_id = 0;
}
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 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;
}
public function setCapiUserId($capi_user_id)
{
$this->capi_user_id = $capi_user_id;
}
public function getCapiUserId()
{
return $this->capi_user_id;
}
}