thanhvocse/history-plugin

OctoberCMS 的模型历史记录

安装次数: 42

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 1

分支: 1

公开问题: 0

类型:october-plugin

v1.0.0 2023-09-20 17:08 UTC

This package is auto-updated.

Last update: 2024-09-20 19:40:23 UTC


README

  • 将修订历史添加到 October CMS 后端。
  • 模型上的每个更新都可以作为修订版追踪,包括用户、时间和详细更改。

要求

  • October CMS 1.0 或更高版本

安装说明

php artisan plugin:install ThanhVoCSE.History

或者

composer require thanhvocse/history-plugin
php artisan october:migrate

控制器行为

配置关系行为和历史行为

class Users extends Controller
{
    public $implement = [
        \Backend\Behaviors\FormController::class,
        \Backend\Behaviors\ListController::class,
        \Backend\Behaviors\RelationController::class,
        \ThanhVoCSE\History\Behaviors\HistoryController::class,
    ];

    public $formConfig = 'config_form.yaml';
    public $listConfig = 'config_list.yaml';
    public $relationConfig = 'config_relation.yaml';
}

然后定义历史关系。以下的历史关系配置仅在你需要自定义时是可选的。

# config_relation.yaml
histories:
    view:
        recordsPerPage: 10
        defaultSort:
            - column: version
            - direction: desc

显示关系管理器

然后可以通过调用关系渲染方法来显示指定关系定义的关系管理器。例如,如果你想在预览页面上显示关系管理器,preview.php 视图内容可能如下所示。

<?= $this->formRenderPreview() ?>

<?= $this->relationRender('histories') ?>

插件设置

此插件创建了一个设置菜单项,可通过导航到设置 > 后端 > 模型历史设置找到。

  • 历史轮换:单个模型记录上最多修订数,超过此数,最旧的修订将被删除。如果你想删除任何旧修订,则将其设置为0。