protected static function boot() {
    parent::boot();

    static::creating(function($node) {
      $node->setDefaultLeftAndRight();
    });

    static::saving(function($node) {
      $node->storeNewParent();
    });

    static::saved(function($node) {
      $node->moveToNewParent();
      $node->setDepth();
    });

    static::deleting(function($node) {
      $node->destroyDescendants();
    });

    if ( static::softDeletesEnabled() ) {
      static::restoring(function($node) {
        $node->shiftSiblingsForRestore();
      });

      static::restored(function($node) {
        $node->restoreDescendants();
      });
    }
  }
protected static function boot() {
    parent::boot();

    static::creating(function($node) {
      $node->setDefaultLeftAndRight();
    });

    static::saving(function($node) {
      $node->storeNewParent();
    });

    static::saved(function($node) {
      $node->moveToNewParent();
      $node->setDepth();
    });

    static::deleting(function($node) {
      $node->destroyDescendants();
    });

    if ( static::softDeletesEnabled() ) {
      static::restoring(function($node) {
        $node->shiftSiblingsForRestore();
      });

      static::restored(function($node) {
        $node->restoreDescendants();
      });
    }
  }
protected static function boot ( ) { parent :: boot ( ) ; static :: creating ( function ( $ node ) { $ node -> setDefaultLeftAndRight ( ) ; } ) ; static :: saving ( function ( $ node ) { $ node -> storeNewParent ( ) ; } ) ; static :: saved ( function ( $ node ) { $ node -> moveToNewParent ( ) ; $ node -> setDepth ( ) ; } ) ; static :: deleting ( function ( $ node ) { $ node -> destroyDescendants ( ) ; } ) ; if ( static :: softDeletesEnabled ( ) ) { static :: restoring ( function ( $ node ) { $ node -> shiftSiblingsForRestore ( ) ; } ) ; static :: restored ( function ( $ node ) { $ node -> restoreDescendants ( ) ; } ) ; } }
The "booting" method of the model.

We'll use this method to register event listeners on a Node instance as
suggested in the beta documentation...

TODO:

- Find a way to avoid needing to declare the called methods "public"
as registering the event listeners *inside* this methods does not give
us an object context.

Events:

1. "creating": Before creating a new Node we'll assign a default value
for the left and right indexes.

2. "saving": Before saving, we'll perform a check to see if we have to
move to another parent.

3. "saved": Move to the new parent after saving if needed and re-set
depth.

4. "deleting": Before delete we should prune all children and update
the left and right indexes for the remaining nodes.

5. (optional) "restoring": Before a soft-delete node restore operation,
shift its siblings.

6. (optional) "restore": After having restored a soft-deleted node,
restore all of its descendants.

@return void
The booting method of the model .