From 893bb38c9305d625d59c93781444fcc329581647 Mon Sep 17 00:00:00 2001 From: Amir Dashti Date: Mon, 22 Mar 2021 13:21:35 +0100 Subject: [PATCH 1/2] v5 :: Add extra selectableColumns to fixTree method --- src/QueryBuilder.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 61aba6a..fa9fcc6 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -844,17 +844,17 @@ public function isBroken() * Nodes with invalid parent are saved as roots. * * @param null|NodeTrait|Model $root - * + * @param array $extra * @return int The number of changed nodes */ - public function fixTree($root = null) + public function fixTree($root = null, array $extraColumns = []) { $columns = [ $this->model->getKeyName(), $this->model->getParentIdName(), $this->model->getLftName(), $this->model->getRgtName(), - ]; + ] + $extraColumns; $dictionary = $this->model ->newNestedSetQuery() From 1e003346d4673759ab41484c7fa3e1d575df54c4 Mon Sep 17 00:00:00 2001 From: Amir Dashti Date: Mon, 22 Mar 2021 13:31:42 +0100 Subject: [PATCH 2/2] v5 :: Correctly merge extraColumns in fixTree method --- src/QueryBuilder.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index fa9fcc6..7e73999 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -844,17 +844,17 @@ public function isBroken() * Nodes with invalid parent are saved as roots. * * @param null|NodeTrait|Model $root - * @param array $extra + * @param array $extraColumns * @return int The number of changed nodes */ public function fixTree($root = null, array $extraColumns = []) { - $columns = [ + $columns = array_merge([ $this->model->getKeyName(), $this->model->getParentIdName(), $this->model->getLftName(), $this->model->getRgtName(), - ] + $extraColumns; + ], $extraColumns); $dictionary = $this->model ->newNestedSetQuery()