laravel-nestedset
laravel-nestedset copied to clipboard
Problem with fixTree and not null parent_id
Hello, i have a problem when adding nestedset to running project. my project using parentid as a parent_id key so i add this line into my model
public function getParentIdName()
{
return 'parentid';
}
but when running MyModel::fixTree(); some parent_id record goes NULL, i have double check that parentid was exist on database.
PS . my old application using parentid 0 zero when not having a parent (root directory)
thanks
In NodeTraite file find:
protected function setParent($value)
{
$this->setParentId($value ? $value->getKey() : null)
->setRelation('parent', $value);
return $this;
}
Change to 0 :)