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

Node must exists.

Open aqshah20 opened this issue 3 years ago • 8 comments

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

aqshah20 avatar Sep 05 '22 13:09 aqshah20

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();
});

leandrodiogenes avatar Sep 05 '22 13:09 leandrodiogenes

Hello Leandro Diógenes,

It added working fine on localhost but having issue on production

On Mon, Sep 5, 2022 at 6:17 PM Leandro Diógenes @.***> wrote:

Hi @aqshah20 https://github.com/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(); });

— Reply to this email directly, view it on GitHub https://github.com/lazychaser/laravel-nestedset/issues/564#issuecomment-1237012251, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKV6PBWB3HDKTGXLYQUTRTV4XXGVANCNFSM6AAAAAAQE7M6AI . You are receiving this because you were mentioned.Message ID: @.***>

aqshah20 avatar Sep 06 '22 06:09 aqshah20

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

leandrodiogenes avatar Sep 06 '22 06:09 leandrodiogenes

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

aqshah20 avatar Sep 06 '22 06:09 aqshah20

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

leandrodiogenes avatar Sep 06 '22 06:09 leandrodiogenes

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

aqshah20 avatar Sep 06 '22 06:09 aqshah20

@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();
}

antonioribeiro avatar Dec 21 '22 10:12 antonioribeiro

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.

Oreolek avatar Oct 05 '23 09:10 Oreolek