From 10d4b7516275d170f16ae652bb97807984676d5d Mon Sep 17 00:00:00 2001 From: Milad Ghazi Date: Thu, 21 Jul 2016 10:18:02 +0430 Subject: [PATCH 1/2] Update Node.php Use Qualified Key Name to enable Joins to the Node and prevent key name (usually ID) field Integrity Errors of mysql. --- src/Baum/Node.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Baum/Node.php b/src/Baum/Node.php index 8dcab130..947f7cc3 100644 --- a/src/Baum/Node.php +++ b/src/Baum/Node.php @@ -468,7 +468,7 @@ public static function buildTree($nodeList) { * @return \Illuminate\Database\Query\Builder */ public function scopeWithoutNode($query, $node) { - return $query->where($node->getKeyName(), '!=', $node->getKey()); + return $query->where($node->getQualifiedKeyName(), '!=', $node->getKey()); } /** From 08e154d8d4f46002d297c2f4cb9963d8384ade76 Mon Sep 17 00:00:00 2001 From: Milad Ghazi Date: Thu, 21 Jul 2016 10:23:59 +0430 Subject: [PATCH 2/2] Update Node.php --- src/Baum/Node.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Baum/Node.php b/src/Baum/Node.php index 947f7cc3..238b6e15 100644 --- a/src/Baum/Node.php +++ b/src/Baum/Node.php @@ -568,8 +568,8 @@ public function getRoot() { */ public function ancestorsAndSelf() { return $this->newNestedSetQuery() - ->where($this->getLeftColumnName(), '<=', $this->getLeft()) - ->where($this->getRightColumnName(), '>=', $this->getRight()); + ->where($this->getQualifiedLeftColumnName(), '<=', $this->getLeft()) + ->where($this->getQualifiedRightColumnName(), '>=', $this->getRight()); } /** @@ -723,8 +723,8 @@ public function getTrunks($columns = array('*')) { */ public function descendantsAndSelf() { return $this->newNestedSetQuery() - ->where($this->getLeftColumnName(), '>=', $this->getLeft()) - ->where($this->getLeftColumnName(), '<', $this->getRight()); + ->where($this->getQualifiedLeftColumnName(), '>=', $this->getLeft()) + ->where($this->getQualifiedLeftColumnName(), '<', $this->getRight()); } /**