Boot the role model
Attach event listener to remove the many-to-many records when trying to delete
Will NOT delete any records if the role model uses soft deletes.

@return void|bool
768831
public static function bootEntrustRoleTrait()
    {
        static::deleting(function ($role) {
            if (! method_exists(Config::get('entrust.role'), 'bootSoftDeletes')) {
                $role->users()->sync([]);
                $role->perms()->sync([]);
            }

            return true;
        });
    }
717899
public static function boot()
    {
        parent::boot();

        static::deleting(function (Discussion $discussion) {
            Notification::whereSubjectModel(Post::class)
                ->whereIn('subject_id', function ($query) use ($discussion) {
                    $query->select('id')->from('posts')->where('discussion_id', $discussion->id);
                })
                ->delete();
        });

        static::deleted(function (Discussion $discussion) {
            $discussion->raise(new Deleted($discussion));

            Notification::whereSubject($discussion)->delete();
        });

        static::saving(function (Discussion $discussion) {
            $event = new GetModelIsPrivate($discussion);

            $discussion->is_private = static::$dispatcher->until($event) === true;
        });
    }
207047
protected static function boot()
    {
        parent::boot();

        self::$buildQueryScopeDefaults['columns'] = [
            'id',
            'poll_id',
            'answer',
        ];

        self::$buildQueryScopeDefaults['relations'] = [
            'voters' => function (BelongsToMany $votersQuery) {
                $votersQuery->select(['id', 'name', 'email']);
            },

            'votes' => function (HasMany $votesQuery) {
                $votesQuery->select(['id', 'user_id', 'option_id']);
            },

            'poll' => function (BelongsTo $pollQuery) {
                $pollQuery->select(['id', 'question', 'single', 'closed']);
            },
        ];
    }
120384
protected static function boot()
    {
        parent::boot();

        static::deleting(function ($comment) {
            $comment->where('parent_id', $comment->id)->get(['id'])->each->delete();
        });
    }
644181
public function boot()
    {
        if ($this->booted) {
            return;
        }

        $this->booted = true;

        foreach ($this->providers as $provider) {
            if ($provider instanceof EventListenerProviderInterface) {
                $provider->subscribe($this, $this['dispatcher']);
            }

            if ($provider instanceof BootableProviderInterface) {
                $provider->boot($this);
            }
        }
    }
889044
protected static function boot()
    {
        parent::boot();

        self::saving(
            function ($theme) {
                Event::fire('theme:saving', [$theme]);
            }
        );

        self::saved(
            function ($theme) {
                Event::fire('theme:saved', [$theme]);
            }
        );

        self::updating(
            function ($theme) {
                Event::fire('theme:updating', [$theme]);
            }
        );

        self::creating(
            function ($theme) {
                Event::fire('theme:creating', [$theme]);
            }
        );

        self::created(
            function ($theme) {
                Event::fire('theme:created', [$theme]);
            }
        );

        self::updated(
            function ($theme) {
                Event::fire('theme:updated', [$theme]);
            }
        );

        self::deleting(
            function ($theme) {
                Event::fire('theme:deleting', [$theme]);
            }
        );

        self::deleted(
            function ($theme) {
                Event::fire('theme:deleted', [$theme]);
            }
        );
    }
265750
public function delete(): bool
    {
        $isSoftDeleted = array_key_exists('Illuminate\Database\Eloquent\SoftDeletes', class_uses($this));
        if ($this->exists && ! $isSoftDeleted) {
            $this->roles()->detach();
        }

        return parent::delete();
    }
1070176
public function boot()
    {
        $events = $this->app->make('events');
        //$events->listen('datatables:*:before.action.edit', DatatableDependableActions::class);
        $events->listen(BeforeTableAction::class, DatatableDependableActions::class);
        //$events->listen('datatables:*:after.massactions.action.delete', DatatableMassActionsDependableActions::class);
        $events->listen(AfterMassActionsAction::class, DatatableMassActionsDependableActions::class);
        //$events->listen('breadcrumb.before.render.*', BreadcrumbsMenuDependableActions::class);

        $events->listen(BreadcrumbBeforeRender::class, BreadcrumbsMenuDependableActions::class);
    }
497108
public static function boot()
    {
        parent::boot();

        static::saving(function ($model) {
            $model->preSave();
        });

        static::saved(function ($model) {
            $model->postSave();
        });

        static::deleted(function ($model) {
            $model->preSave();
            $model->postDelete();
        });
    }
1286051
public static function bootRevisionableTrait()
    {
        static::saving(function ($model) {
            $model->preSave();
        });

        static::saved(function ($model) {
            $model->postSave();
        });

        static::created(function ($model) {
            $model->postCreate();
        });

        static::deleted(function ($model) {
            $model->preSave();
            $model->postDelete();
        });
    }
1311234
public static function bootLaratrustTeamTrait()
    {
        static::deleting(function ($team) {
            if (method_exists($team, 'bootSoftDeletes') && !$team->forceDeleting) {
                return;
            }

            foreach (array_keys(Config::get('laratrust.user_models')) as $key) {
                $team->$key()->sync([]);
            }
        });
    }
213148
protected function deleteUserRole()
    {
        $this->controlAccess('user_role_delete');

        if ($this->role->delete($this->data_role['role_id'])) {
            $this->redirect('admin/user/role', $this->text('Role has been deleted'), 'success');
        }

        $this->redirect('', $this->text('Role has not been deleted'), 'warning');
    }
837901
protected static function bootNtrustRoleTrait()
    {
        static::saved(function() {
            self::clearCache();
        });

        static::deleted(function($role) {
            self::clearCache($role);
        });

        if(method_exists(self::class, 'restored')) {
            static::restored(function($role) {
                self::clearCache($role);
            });
        }
    }
725120
public function bootEloquent()
    {
        Eloquent::setConnectionResolver($this->manager);

        // If we have an event dispatcher instance, we will go ahead and register it
        // with the Eloquent ORM, allowing for model callbacks while creating and
        // updating "model" instances; however, it is not necessary to operate.
        if ($dispatcher = $this->getEventDispatcher()) {
            Eloquent::setEventDispatcher($dispatcher);
        }
    }
242884
public function boot()
    {
        $app = $this->app;

        // Listen to log messages.
        $app['log']->listen(function ($level, $message, $context) use ($app) {
            $app['rollbar.handler']->log($level, $message, $context);
        });
    }
465532
protected static function boot ()
    {
        parent::boot ();

        /**
         * Attach to the 'creating' Model Event to provide a UUID
         * for the `id` field (provided by $model->getKeyName())
         */
        static::creating (function ($model)
        {
            if (!isset($model->attributes['id']))
                $model->attributes['id'] = uuid4 ();

            $model->{$model->getKeyName ()} = $model->attributes['id'];
        });
    }
1263672
public static function bootMetable()
	{
		static::saved(function ($model) {
			$model->syncMetableTableAttributes();
		});
		
		static::deleted(function ($model) {
			$model->handleDeletedModelMetas();
		});
		
		static::registerModelEvent('restored', function ($model) {
			$model->handleRestoredModelMetas();
		});
	}