diff --git a/Controller/API/AttributeController.php b/Controller/API/AttributeController.php index 1293f0f..15b6d02 100644 --- a/Controller/API/AttributeController.php +++ b/Controller/API/AttributeController.php @@ -78,6 +78,12 @@ class AttributeController extends BaseController { $this->arrQueryStringParams = $this->getQueryStringParams(); + if (isset($this->arrQueryStringParams['loyalty_attribute_name'])) { + $this->attributeModel->attributeName = $this->arrQueryStringParams['loyalty_attribute_name']; + $this->attributeModel->memberId = $this->arrQueryStringParams['loyalty_member_id']; + return $this->attributeModel->findMemberAttributeByAttrName(); + } + if (isset($this->arrQueryStringParams['loyalty_member_id'])) { $response = $this->selectByMemberIdAction(); } else { diff --git a/Model/AttributeModel.php b/Model/AttributeModel.php index 116a84d..f7d6f99 100644 --- a/Model/AttributeModel.php +++ b/Model/AttributeModel.php @@ -14,20 +14,33 @@ class AttributeModel extends Database { public function findAllAttributes() { - return $this->processQuery("SELECT * FROM loyalty_attribute ORDER BY loyalty_attribute_id ASC"); + $response = $this->processQuery("SELECT * FROM loyalty_attribute ORDER BY loyalty_attribute_id ASC"); + return $response; } public function findAttributesByMemberId() { - return $this->processQuery("SELECT * FROM loyalty_member_view WHERE loyalty_member_id = ?", ["i", $this->memberId]); + $response = $this->processQuery("SELECT * FROM loyalty_member_view WHERE loyalty_member_id = ?", ["i", $this->memberId]); + return $response; } - public function findMemberAttribute() + public function findMemberAttributeByAttrId() { $query = "SELECT * FROM loyalty_member_view WHERE loyalty_member_id = " . $this->memberId; $query .= " AND loyalty_attribute_id = " . $this->attributeId; - return $this->processQuery($query); + $response = $this->processQuery($query); + return $response; + } + + public function findMemberAttributeByAttrName() + { + $query = "SELECT loyalty_attribute_id FROM loyalty_attribute WHERE loyalty_attribute_name = '" . $this->attributeName . "'"; + $data = $this->processQuery($query); + $this->attributeId = $data[0]['loyalty_attribute_id']; + + $response = $this->findMemberAttributeByAttrId(); + return $response; } public function insertAttribute($inputModel)