@@ -86,7 +86,7 @@ public function whereIsRoot()
8686 */
8787 public function whereAncestorOf ($ id , $ andSelf = false , $ boolean = 'and ' )
8888 {
89- $ keyName = $ this ->model ->getKeyName ();
89+ $ keyName = $ this ->model ->getTable () . ' . ' . $ this -> model -> getKeyName ();
9090
9191 if (NestedSet::isNode ($ id )) {
9292 $ value = '? ' ;
@@ -100,21 +100,21 @@ public function whereAncestorOf($id, $andSelf = false, $boolean = 'and')
100100 ->toBase ()
101101 ->select ("_. " .$ this ->model ->getRgtName ())
102102 ->from ($ this ->model ->getTable ().' as _ ' )
103- ->where ($ keyName , '= ' , $ id )
103+ ->where ($ this -> model -> getKeyName () , '= ' , $ id )
104104 ->limit (1 );
105105
106106 $ this ->query ->mergeBindings ($ valueQuery );
107107
108108 $ value = '( ' .$ valueQuery ->toSql ().') ' ;
109109 }
110110
111- $ this ->query ->whereNested (function ($ inner ) use ($ value , $ andSelf , $ id ) {
111+ $ this ->query ->whereNested (function ($ inner ) use ($ value , $ andSelf , $ id, $ keyName ) {
112112 list ($ lft , $ rgt ) = $ this ->wrappedColumns ();
113113
114114 $ inner ->whereRaw ("{$ value } between {$ lft } and {$ rgt }" );
115115
116116 if ( ! $ andSelf ) {
117- $ inner ->where ($ this -> model -> getKeyName () , '<> ' , $ id );
117+ $ inner ->where ($ keyName , '<> ' , $ id );
118118 }
119119 }, $ boolean );
120120
0 commit comments