moonshine/changelog

MoonShine 模型 ChangeLog

1.0.3 2024-05-02 13:11 UTC

This package is auto-updated.

Last update: 2024-09-02 13:49:17 UTC


README

需求

  • MoonShine v2.0+

安装

composer require moonshine/changelog
php artisan migrate

开始使用

将特性 HasChangeLog 添加到模型

class Post extends Model
{
    use HasChangeLog;
}

将组件添加到页面

protected function bottomLayer(): array
{
    return [
        ...parent::bottomLayer(),

        ChangeLog::make('Changelog', $this->getResource())
    ];
}

或在资源中

class PostResource extends ModelResource
{
    // ...
    protected function onBoot(): void
    {
        $this->getPages()
                ->formPage()
                ->pushToLayer(
                    Layer::BOTTOM,
                    ChangeLog::make('Changelog', $this)
                );
    }
    // ...
}

默认情况下,显示最后5个更改。要更改此设置,请使用 limit() 方法

ChangeLog::make('Changelog', $this)->limit(10)