'Reorder operation is not working in backpack for laravel

Reorder operation is not working in backpack for laravel.

Migration file:

 public function up()
    {
        Schema::table('complexities', function (Blueprint $table) {
            $table->integer('parent_id')->default(0)->nullable();
            $table->integer('lft')->default(0)->nullable();
            $table->integer('rgt')->default(0)->nullable();
            $table->integer('depth')->default(0)->nullable();
        });
    }

Crud controller

use ReorderOperation;
..........
.........
protected function setupReorderOperation()
    {
        $this->crud->set('reorder.label', 'title');
        $this->crud->set('reorder.max_level', 2);
    }

I am getting the Reorder UI, But it is not working. I mean can reorder the list, But no effect in database and list becomes in old order when I reload it.



Solution 1:[1]

Not sure about the nullable on all fields. Please try with

public function up()
{
    Schema::table('complexities', function (Blueprint $table) {
        $table->integer('parent_id')->nullable()->default(0);
        $table->integer('lft')->default(0);
        $table->integer('rgt')->default(0);
        $table->integer('depth')->default(0);
    });
}

Also check if there are any values stored for these fields in the database.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 o15a3d4l11s2