@@ -45,37 +45,37 @@ public static function bootNodeTrait()
4545 {
4646 static ::saving (function (self $ model ) {
4747 $ model ->getConnection ()->beginTransaction ();
48-
48+
4949 return $ model ->callPendingAction ();
5050 });
51-
51+
5252 static ::saved (function (self $ model ) {
5353 $ model ->getConnection ()->commit ();
5454 });
5555
5656 static ::deleting (function (self $ model ) {
5757 $ model ->getConnection ()->beginTransaction ();
58-
58+
5959 // We will need fresh data to delete node safely
6060 $ model ->refreshNode ();
6161 });
6262
6363 static ::deleted (function (self $ model ) {
6464 $ model ->deleteDescendants ();
65-
65+
6666 $ model ->getConnection ()->commit ();
6767 });
6868
6969 if (static ::usesSoftDelete ()) {
7070 static ::restoring (function (self $ model ) {
7171 $ model ->getConnection ()->beginTransaction ();
72-
72+
7373 static ::$ deletedAt = $ model ->{$ model ->getDeletedAtColumn ()};
7474 });
7575
7676 static ::restored (function (self $ model ) {
7777 $ model ->restoreDescendants (static ::$ deletedAt );
78-
78+
7979 $ model ->getConnection ()->commit ();
8080 });
8181 }
@@ -197,8 +197,8 @@ protected function actionAppendOrPrepend(self $parent, $prepend = false)
197197 */
198198 protected function setParent ($ value )
199199 {
200- $ this ->attributes [$ this ->getParentIdName ()] = $ value
201- ? $ value ->getKey ()
200+ $ this ->attributes [$ this ->getParentIdName ()] = $ value
201+ ? $ value ->getKey ()
202202 : null ;
203203
204204 $ this ->setRelation ('parent ' , $ value );
@@ -805,9 +805,7 @@ public function getParentIdName()
805805 */
806806 public function getLft ()
807807 {
808- return isset ($ this ->attributes [$ this ->getLftName ()])
809- ? $ this ->attributes [$ this ->getLftName ()]
810- : null ;
808+ return $ this ->getAttributeValue ($ this ->getLftName ());
811809 }
812810
813811 /**
@@ -817,9 +815,7 @@ public function getLft()
817815 */
818816 public function getRgt ()
819817 {
820- return isset ($ this ->attributes [$ this ->getRgtName ()])
821- ? $ this ->attributes [$ this ->getRgtName ()]
822- : null ;
818+ return $ this ->getAttributeValue ($ this ->getRgtName ());
823819 }
824820
825821 /**
@@ -829,14 +825,14 @@ public function getRgt()
829825 */
830826 public function getParentId ()
831827 {
832- return $ this ->getAttribute ($ this ->getParentIdName ());
828+ return $ this ->getAttributeValue ($ this ->getParentIdName ());
833829 }
834830
835831 /**
836832 * Returns node that is next to current node without constraining to siblings.
837- *
833+ *
838834 * This can be either a next sibling or a next sibling of the parent node.
839- *
835+ *
840836 * @param array $columns
841837 *
842838 * @return self
@@ -850,7 +846,7 @@ public function getNextNode(array $columns = array( '*' ))
850846 * Returns node that is before current node without constraining to siblings.
851847 *
852848 * This can be either a prev sibling or parent node.
853- *
849+ *
854850 * @param array $columns
855851 *
856852 * @return self
@@ -943,7 +939,7 @@ public function getPrevSibling(array $columns = array( '*' ))
943939 */
944940 public function isDescendantOf (self $ other )
945941 {
946- return $ this ->getLft () > $ other ->getLft () &&
942+ return $ this ->getLft () > $ other ->getLft () &&
947943 $ this ->getLft () < $ other ->getRgt ();
948944 }
949945
@@ -1029,15 +1025,23 @@ public function getBounds()
10291025 */
10301026 public function setLft ($ value )
10311027 {
1032- $ this ->setAttribute ( $ this ->getLftName (), $ value) ;
1028+ $ this ->attributes [ $ this ->getLftName ()] = $ value ;
10331029 }
10341030
10351031 /**
10361032 * @param $value
10371033 */
10381034 public function setRgt ($ value )
10391035 {
1040- $ this ->setAttribute ($ this ->getRgtName (), $ value );
1036+ $ this ->attributes [$ this ->getRgtName ()] = $ value ;
1037+ }
1038+
1039+ /**
1040+ * @param $value
1041+ */
1042+ public function setParentId ($ value )
1043+ {
1044+ $ this ->attributes [$ this ->getParentIdName ()] = $ value ;
10411045 }
10421046
10431047}
0 commit comments