From 6898b9989e3ac7631b43afa51c1c9a565dafdec1 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Tue, 20 Oct 2020 07:01:01 +0800 Subject: [PATCH 1/3] Add date_create and date_update fields in Battery entity #522 --- src/Entity/Battery.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Entity/Battery.php b/src/Entity/Battery.php index 4c78fb08..8adf4f65 100644 --- a/src/Entity/Battery.php +++ b/src/Entity/Battery.php @@ -7,6 +7,8 @@ use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; +use DateTime; + /** * @ORM\Entity * @ORM\Table(name="battery") @@ -21,6 +23,16 @@ class Battery */ protected $id; + /** + * @ORM\Column(type="datetime") + */ + protected $date_create; + + /** + * @ORM\Column(type="datetime", columnDefinition="timestamp default current_timestamp on update current_timestamp") + */ + protected $date_update; + // manufacturer /** * @ORM\ManyToOne(targetEntity="BatteryManufacturer", inversedBy="batteries") @@ -145,6 +157,8 @@ class Battery $this->width = 0; $this->height = 0; $this->total_height = 0; + + $this->date_create = new DateTime(); } public function getID() @@ -152,6 +166,16 @@ class Battery return $this->id; } + public function getDateCreate() + { + return $this->date_create; + } + + public function getDateUpdate() + { + return $this->date_update; + } + public function setManufacturer($manufacturer) { $this->manufacturer = $manufacturer; From 74928f196b52f4d4467e93e51b8fed951b75122c Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Tue, 20 Oct 2020 07:38:47 +0800 Subject: [PATCH 2/3] Add date_create and date_update to SAPBattery entity #522 --- src/Entity/SAPBattery.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Entity/SAPBattery.php b/src/Entity/SAPBattery.php index 4a482b43..c57dce8d 100644 --- a/src/Entity/SAPBattery.php +++ b/src/Entity/SAPBattery.php @@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; +use DateTime; /** * @ORM\Entity @@ -20,6 +21,16 @@ class SAPBattery */ protected $id; + /** + * @ORM\Column(type="datetime") + */ + protected $date_create; + + /** + * @ORM\Column(type="datetime", columnDefinition="timestamp default current_timestamp on update current_timestamp") + */ + protected $date_update; + // brand /** * @ORM\ManyToOne(targetEntity="SAPBatteryBrand", inversedBy="batteries") @@ -37,6 +48,7 @@ class SAPBattery public function __construct() { + $this->date_create = new DateTime(); } public function setID($id) @@ -50,6 +62,16 @@ class SAPBattery return $this->id; } + public function getDateCreate() + { + return $this->date_create; + } + + public function getDateUpdate() + { + return $this->date_update; + } + public function setBrand($brand) { $this->brand = $brand; From 7ca467ce4cfd56150d838e0b8f175207e0eb9af0 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Tue, 20 Oct 2020 07:52:07 +0800 Subject: [PATCH 3/3] Add date_update to battery list CAPI #522 --- src/Controller/CAPI/BatteryController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Controller/CAPI/BatteryController.php b/src/Controller/CAPI/BatteryController.php index 02ce3104..22064a9d 100644 --- a/src/Controller/CAPI/BatteryController.php +++ b/src/Controller/CAPI/BatteryController.php @@ -37,6 +37,7 @@ class BatteryController extends APIController 'id' => $batt->getID(), 'size' => $batt->getSize()->getID(), 'brand' => $batt->getBrand()->getID(), + 'date_update' => $batt->getDateUpdate()->format('YmdHis'), ]; }