diff --git a/src/Controller/CustomerAppAPI/ApiController.php b/src/Controller/CustomerAppAPI/ApiController.php index 577a05a6..635a3c45 100644 --- a/src/Controller/CustomerAppAPI/ApiController.php +++ b/src/Controller/CustomerAppAPI/ApiController.php @@ -14,6 +14,7 @@ use App\Entity\Warranty; use App\Entity\JobOrder; use App\Entity\CustomerSession; use App\Service\PayMongoConnector; +use DateTime; class ApiController extends BaseApiController { @@ -64,6 +65,9 @@ class ApiController extends BaseApiController } } + // update session timestamp + $this->updateSessionTimestamp(); + return [ 'is_valid' => !$error, 'error' => $error, @@ -173,4 +177,10 @@ class ApiController extends BaseApiController $this->getParameter('subscription_paymongo_secret_key'), ); } + + protected function updateSessionTimestamp() + { + $this->session->setDateLatestActivity(new DateTime()); + $this->em->flush(); + } } diff --git a/src/Entity/CustomerSession.php b/src/Entity/CustomerSession.php index a8e2d6c6..0b45c76d 100644 --- a/src/Entity/CustomerSession.php +++ b/src/Entity/CustomerSession.php @@ -100,6 +100,12 @@ class CustomerSession */ protected $date_code_sent; + // date and time this session was last used + /** + * @ORM\Column(type="datetime", nullable=true) + */ + protected $date_latest_activity; + // reviews made by mobile session /** * @ORM\OneToMany(targetEntity="Review", mappedBy="mobile_session") @@ -115,6 +121,7 @@ class CustomerSession $this->confirm_flag = false; $this->date_confirmed = null; $this->date_code_sent = null; + $this->date_latest_activity = null; $this->reviews = new ArrayCollection(); } @@ -270,4 +277,15 @@ class CustomerSession { return $this->reviews; } + + public function setDateLatestActivity(DateTime $date) + { + $this->date_latest_activity = $date; + return $this; + } + + public function getDateLatestActivity() + { + return $this->date_latest_activity; + } }