diff --git a/src/Controller/CustomerTagController.php b/src/Controller/CustomerTagController.php index ab4178f5..680b9ae6 100644 --- a/src/Controller/CustomerTagController.php +++ b/src/Controller/CustomerTagController.php @@ -139,7 +139,8 @@ class CustomerTagController extends Controller $obj = new CustomerTag(); $obj->setID($req->request->get('id')) - ->setName($req->request->get('name')); + ->setName($req->request->get('name')) + ->setTagDetails($req->request->get('tag_details')); // validate $errors = $validator->validate($obj); @@ -206,7 +207,8 @@ class CustomerTagController extends Controller throw $this->createNotFoundException('The item does not exist'); $obj->setID($req->request->get('id')) - ->setName($req->request->get('name')); + ->setName($req->request->get('name')) + ->setTagDetails($req->request->get('tag_details')); // validate $errors = $validator->validate($obj); diff --git a/src/Entity/CustomerTag.php b/src/Entity/CustomerTag.php index aa80e2e7..6aa506da 100644 --- a/src/Entity/CustomerTag.php +++ b/src/Entity/CustomerTag.php @@ -33,10 +33,17 @@ class CustomerTag */ protected $customers; + // tag details + /** + * @ORM\Column(type="json") + */ + protected $tag_details; + public function __construct() { $this->date_create = new DateTime(); $this->customers = new ArrayCollection(); + $this->tag_details = []; } public function getID() @@ -83,4 +90,30 @@ class CustomerTag { return $this->customers; } + + public function addTagDetails($id, $value) + { + $this->tag_details[$id] = $value; + return $this; + } + + public function setTagDetails($tag_details) + { + $this->tag_details = $tag_details; + return $this; + } + + public function getTagDetails($id) + { + // return null if we don't have it + if (!isset($this->tag_details[$id])) + return null; + + return $this->tag_details[$id]; + } + + public function getAllTagDetails() + { + return $this->tag_details; + } } diff --git a/templates/customer-tag/form.html.twig b/templates/customer-tag/form.html.twig index ce574a44..778378f6 100644 --- a/templates/customer-tag/form.html.twig +++ b/templates/customer-tag/form.html.twig @@ -54,6 +54,16 @@
+