Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue #513 #514

Open
wants to merge 2 commits into
base: v5
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixes
nagmat84 committed May 30, 2021
commit 93f9579cf097b945241154c2de7526c72ab72e9c
8 changes: 4 additions & 4 deletions src/NodeTrait.php
Original file line number Diff line number Diff line change
@@ -249,7 +249,7 @@ public function children()
*/
public function descendants()
{
return new DescendantsRelation($this->newQuery(), $this);
return new DescendantsRelation($this->newQueryWithoutScopes(), $this);
}

/**
@@ -338,7 +338,7 @@ public function prevNodes()
*/
public function ancestors()
{
return new AncestorsRelation($this->newQuery(), $this);
return new AncestorsRelation($this->newQueryWithoutScopes(), $this);
}

/**
@@ -675,7 +675,7 @@ public function newNestedSetQuery($table = null)
{
$builder = $this->usesSoftDelete()
? $this->withTrashed()
: $this->newQuery();
: $this->newQueryWithoutScopes();

return $this->applyNestedSetScope($builder, $table);
}
@@ -687,7 +687,7 @@ public function newNestedSetQuery($table = null)
*/
public function newScopedQuery($table = null)
{
return $this->applyNestedSetScope($this->newQuery(), $table);
return $this->applyNestedSetScope($this->newQueryWithoutScopes(), $table);
}

/**
17 changes: 10 additions & 7 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
@@ -31,18 +31,21 @@ class QueryBuilder extends Builder
*/
public function getNodeData($id, $required = false)
{
$query = $this->toBase();
$lftName = $this->model->getLftName();
$rgtName = $this->model->getRgtName();

$query->where($this->model->getKeyName(), '=', $id);

$data = $query->first([ $this->model->getLftName(),
$this->model->getRgtName() ]);
$data = $this->toBase()
->where($this->model->getKeyName(), '=', $id)
->first([$lftName, $rgtName]);

if ( ! $data && $required) {
throw new ModelNotFoundException;
}

return (array)$data;
// Ensure that the result only contains the required attributes in
// correct order and nothing else.
// The query above might accidentally return more attributes, if
// a global scope is defined for the query by the base model.
return $data ? [$lftName => $data[$lftName], $rgtName => $data[$rgtName]] : [];
}

/**