Skip to content
New issue

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

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

Already on GitHub? # to your account

Node must exists. #564

Open
aqshah20 opened this issue Sep 5, 2022 · 8 comments
Open

Node must exists. #564

aqshah20 opened this issue Sep 5, 2022 · 8 comments

Comments

@aqshah20
Copy link

aqshah20 commented Sep 5, 2022

Hello developer team how can I fix this error on production?
even its working fine on my localhost

@leandrodiogenes
Copy link

Hi @aqshah20 check your table structure.
Make sure you have added the nested fields on your table migration

Schema::create('table', function (Blueprint $table) {
    ...
    $table->nestedSet();
});

@aqshah20
Copy link
Author

aqshah20 commented Sep 6, 2022 via email

@leandrodiogenes
Copy link

Check your tablet structure, maybe there is something missing on production table

@aqshah20
Copy link
Author

aqshah20 commented Sep 6, 2022

I checked local and production table structure is same but don't know why having issue

@leandrodiogenes
Copy link

leandrodiogenes commented Sep 6, 2022

That error is trown when you dont have values on lft and rgt Fields of any node, check your tablet data.

@aqshah20
Copy link
Author

aqshah20 commented Sep 6, 2022

one thing more in my table already has more than 1000 rows than how I can update nodes?

@antonioribeiro
Copy link

@aqshah20, this is what I did to fix my existing records:

$counter = 1;

foreach (Posts::orderBy('id')->get() as $post) {
    $post->_lft = $counter++;

    $post->_rgt = $counter++;

    $post->save();
}

@Oreolek
Copy link

Oreolek commented Oct 5, 2023

Fresh install, but this is still present:

   protected function assertNodeExists(self $node)
    {
        if ( ! $node->getLft() || ! $node->getRgt()) {
            throw new LogicException('Node must exists.');
        }
        return $this;
    }

and the package often sets _lft or _rgt to zero and then complains.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants