Open sobhanatar opened 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.
Laravel 5.3
id
name
categories
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.
immediateDescendants()
getImmediateDescendants()
get(['id', 'name'])
Hi
I'm using
Laravel 5.3
and when I want to get only two fields ofid
andname
fromcategories
table, it results in empty collection.This is my code:
As the Node.php code shows us the functions is supposed to return the only columns we want:
As an alternative to this I'd used following code but still wondering why it doesn't return what it's supposed to
So I'm using
immediateDescendants()
instead ofgetImmediateDescendants()
which doesn't accept any argument and after that, chained it withget(['id', 'name'])
in my model.