laravel-nestedset icon indicating copy to clipboard operation
laravel-nestedset copied to clipboard

Problem with fixTree and not null parent_id

Open tarikhagustia opened this issue 3 years ago • 1 comments

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

tarikhagustia avatar Nov 25 '21 07:11 tarikhagustia

In NodeTraite file find:

protected function setParent($value)
{
    $this->setParentId($value ? $value->getKey() : null)
        ->setRelation('parent', $value);

    return $this;
}

Change to 0 :)

jkurowski avatar Mar 27 '23 21:03 jkurowski