App\Traits\PermissionHasUsersTrait::boot PHP Method

boot() public static method

Boot the permission model Attach event listener to remove the many-to-many records when trying to delete Will NOT delete any records if the permission model uses soft deletes.
public static boot ( ) : void | boolean
return void | boolean
    public static function boot()
    {
        parent::boot();
        static::deleting(function ($permission) {
            if (!method_exists(Config::get('entrust.permission'), 'bootSoftDeletingTrait')) {
                // Repeat role->sync code attached from EntrustPermissionTrait::boot() as this boot()
                // function overwrites it.
                $permission->roles()->sync([]);
                $permission->users()->sync([]);
            }
            return true;
        });
    }