定制 polashmahmud/history 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

polashmahmud/history

最新稳定版本:v0.0.5

Composer 安装命令:

composer require polashmahmud/history

包简介

A simple laravel history package

README 文档

README

History Tracking System is a Laravel package that provides history tracking functionality for your Eloquent models. Easily add and manage history for your models with this simple and flexible package.

Features

  • History Tracking: Associate history with your Eloquent models.
  • History Tracking Trait: Easily make your models history trackable using the HistoryTracking trait.

Installation

To install History Tracking System, simply run:

composer require polashmahmud/history

Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider. If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

Polashmahmud\History\HistoryTrackingServiceProvider::class,

Then, migrate your database:

php artisan migrate

Usage

History Tracking Models

To make a model history trackable, use the Polashmahmud\History\Historyable trait on the model:

use Polashmahmud\History\Historyable;

class Post extends Model
{
    use Historyable;
}

that's it! Now your model is history trackable. When a model is updated, a history record will be created for it. The history record will contain the model's previous and new values. The history record will also contain the user who made the change. If the user is not logged in, the history record will contain the user's IP address.

Retrieving History

To retrieve the history of a model, use the history method:

$post = Post::find(1);

$history = $post->history;

The history method will return a collection of history records. Each history record will contain the model's previous and new values, the user who made the change, and the date and time the change was made.

Query with changedBy method to get the history records that were made by a specific user:

$history = $post->history()->with('changedBy')->get();

History Tracking Ignore Columns

By default, updated_at, password, remember_token and email_verified_at columns are ignored from history tracking. If you want to ignore more columns, you can use ignoreHistoryColumns function in your model.

use Polashmahmud\History\Historyable;

class Post extends Model
{
    use Historyable;
    
    public function ignoreHistoryColumns()
    {
        return [
            // 'column_name',
        ];
    }
}

History Tracking Scopes

History Tracking System provides some useful scopes to help you retrieve history records.

Coming soon...

Contributing

Thank you for considering contributing to History Tracking ! Please see CONTRIBUTING for details.

License

History Tracking is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 1.19k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固