@@ -43,28 +43,30 @@ trait NodeTrait
4343 */
4444 public static function bootNodeTrait ()
4545 {
46- static ::saving (function ($ model ) {
47- return $ model ->callPendingAction ();
48- });
49-
50- static ::deleting (function ($ model ) {
51- // We will need fresh data to delete node safely
52- $ model ->refreshNode ();
53- });
54-
55- static ::deleted (function ($ model ) {
56- $ model ->deleteDescendants ();
57- });
46+ static ::whenBooted (function () {
47+ static ::saving (function ($ model ) {
48+ return $ model ->callPendingAction ();
49+ });
5850
59- if ( static ::usesSoftDelete () ) {
60- static :: restoring ( function ( $ model ) {
61- static :: $ deletedAt = $ model ->{ $ model -> getDeletedAtColumn ()} ;
51+ static ::deleting ( function ( $ model ) {
52+ // We will need fresh data to delete node safely
53+ $ model ->refreshNode () ;
6254 });
6355
64- static ::restored (function ($ model ) {
65- $ model ->restoreDescendants ( static :: $ deletedAt );
56+ static ::deleted (function ($ model ) {
57+ $ model ->deleteDescendants ( );
6658 });
67- }
59+
60+ if (static ::usesSoftDelete ()) {
61+ static ::restoring (function ($ model ) {
62+ static ::$ deletedAt = $ model ->{$ model ->getDeletedAtColumn ()};
63+ });
64+
65+ static ::restored (function ($ model ) {
66+ $ model ->restoreDescendants (static ::$ deletedAt );
67+ });
68+ }
69+ });
6870 }
6971
7072 /**
0 commit comments