Unable to use move up and move down in cakephp 3

move up and move down function
Class CategoriesController extends AppController {

public function index(){
	$categories = $this->Categories->find()->order(['lft'=>'ASC']);
	$this->set(compact('categories'));

}

public function moveDown(){
$this->request->allowMethod([‘post’,‘put’]);
$category= $this->Categories->get($id);
if($this->Categories->moveDown($category)){
$this->Flash->success(‘category has been moved downn’);
}
return $this->redirect($this->referer([‘action’=>‘index’]));
}
public function moveUp(){
$this->request->allowMethod([‘post’,‘put’]);
$category= $this->Categories->get(2);
if($this->Categories->moveUp($category)){
$this->Flash->success(‘category has been moved up’);
}
return $this->redirect($this->referer([‘action’=>‘index’]));
}
}

information
i am unable to move up and move down. how to decide amough by which we have to move up and move down please clear doubt

I have the same problem…

According to the history of the SQL log, the node will be moved, but there is no change on the list …
I have the order according to lft ASC

UPDATE 
  navigations 
SET 
  rght = (
    (rght + 1174)
  ) 
WHERE 
  (
    rght BETWEEN 13 
    AND 14

Please, give me an advice

If you have categories already present in your table the tree behavior only works if you have called

$categories = TableRegistry::getTableLocator()->get('Categories');
$categories->recover();

ONCE after you have finisihed introducing the tree behaviors functionality.

After that the initial values for lft and rght are being set in the table and both ->moveUp($node); and ->moveDown($node); work as expected

I’ve done it all, I don’t know for not being able to move nodes.

Well if you see the executed SQL does the value of the rght value actually change after you perform the move?

I’m sorry, it works - I noticed that I didn’t sort by lft column.