@@ -86,7 +86,7 @@ public function whereIsRoot()
86
86
*/
87
87
public function whereAncestorOf ($ id , $ andSelf = false , $ boolean = 'and ' )
88
88
{
89
- $ keyName = $ this ->model ->getKeyName ();
89
+ $ keyName = $ this ->model ->getTable () . ' . ' . $ this -> model -> getKeyName ();
90
90
91
91
if (NestedSet::isNode ($ id )) {
92
92
$ value = '? ' ;
@@ -100,21 +100,21 @@ public function whereAncestorOf($id, $andSelf = false, $boolean = 'and')
100
100
->toBase ()
101
101
->select ("_. " .$ this ->model ->getRgtName ())
102
102
->from ($ this ->model ->getTable ().' as _ ' )
103
- ->where ($ keyName , '= ' , $ id )
103
+ ->where ($ this -> model -> getKeyName () , '= ' , $ id )
104
104
->limit (1 );
105
105
106
106
$ this ->query ->mergeBindings ($ valueQuery );
107
107
108
108
$ value = '( ' .$ valueQuery ->toSql ().') ' ;
109
109
}
110
110
111
- $ this ->query ->whereNested (function ($ inner ) use ($ value , $ andSelf , $ id ) {
111
+ $ this ->query ->whereNested (function ($ inner ) use ($ value , $ andSelf , $ id, $ keyName ) {
112
112
list ($ lft , $ rgt ) = $ this ->wrappedColumns ();
113
113
114
114
$ inner ->whereRaw ("{$ value } between {$ lft } and {$ rgt }" );
115
115
116
116
if ( ! $ andSelf ) {
117
- $ inner ->where ($ this -> model -> getKeyName () , '<> ' , $ id );
117
+ $ inner ->where ($ keyName , '<> ' , $ id );
118
118
}
119
119
}, $ boolean );
120
120
0 commit comments