public function editValidate($data = array()) { $getCategory = $this->getId('', $data['name']); //check category exists if ($getCategory) { if (!empty($data['id'])) { // Case : Edit User if ($getCategory['id'] != $data['id']) { self::$error['name'] = 'CategoryName already exists !Please enter a different CategoryName!'; } } else { // Case : Add User self::$error['name'] = 'CategoryName already exists !Please enter a different CategoryName!'; } } $dataValidate = array('name' => $data['name']); $this->validate->dataValidate($dataValidate); //Merge 2 error array self::$error = array_merge($this->validate->getError(), self::$error); if (!empty(self::$error['name'])) { return false; } return true; }