etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 459 forks source link

Bug: passing $columns to getImmediateDescendants() function has no result #257

Open sobhanatar opened 7 years ago

sobhanatar commented 7 years ago

Hi

I'm using Laravel 5.3 and when I want to get only two fields of id and name from categories table, it results in empty collection.

This is my code:

$category->getImmediateDescendants(['id', 'name']);

As the Node.php code shows us the functions is supposed to return the only columns we want:

public function getImmediateDescendants($columns = array('*')) {
    return $this->children()->get($columns);
}

As an alternative to this I'd used following code but still wondering why it doesn't return what it's supposed to

$category->immediateDescendants()->get(['id', 'name']);

So I'm using immediateDescendants() instead of getImmediateDescendants() which doesn't accept any argument and after that, chained it with get(['id', 'name']) in my model.