marshmallow/historytracking

跟踪特定模型上的所有更改。

v1.0.1 2021-04-07 09:56 UTC

This package is auto-updated.

Last update: 2024-09-05 10:38:50 UTC


README

Issues Forks Stars License

Marshmallow 历史跟踪器

通过向要跟踪更改的模型添加特性,记录该模型进行的所有更改。

安装

composer require marshmallow/package-historytracking

当Composer准备就绪后,请确保您创建了所需的表。

php artisan migrate

为了使用 HistoryTracking,您需要将 Historyable 特性添加到您想要跟踪更改的模型中。

namespace App;
use Illuminate\Database\Eloquent\Model;
use Marshmallow\HistoryTracking\Traits\Historyable;

class User extends Model
{
    use Historyable;
}

不跟踪所有列

如果您不希望某些列(例如,用户的密码字段)出现在历史表中,则可以使用以下函数传递这些列。请注意,如果您实现此方法,则将覆盖默认方法。默认方法排除 updated_at 列。如果您覆盖此方法,请务必始终添加该列。

class User extends Model
{
    use Historyable;

    ...

    public function ignoreHistoryColumns ()
    {
        return [
            'password',
            'updated_at'
        ];
    }
}

版权 (c) 2020 marshmallow