承接 alzpk/laravel-change-log 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

alzpk/laravel-change-log

最新稳定版本:v0.1.0

Composer 安装命令:

composer require alzpk/laravel-change-log

包简介

Package that makes it easy to log any changes for your models.

README 文档

README

Package that makes it easy to log any changes for your models. The package uses Laravel's Model Events to log the changes. It will log the changes to the changes relation of the model, when ever a model is created, updated, or deleted.

The package will allow you to revert the latest changes, or revert changes by id, depending on the action.

Setup

  1. Start of by installing the package:
composer require alzpk/laravel-change-log
  1. Publish the package service provider
php artisan vendor:publish --provider="Alzpk\LaravelChangeLog\ChangeLogServiceProvider"
  1. Run the migrations
php artisan migrate

Usage

To use the package, add the trait to the models you want to log:

use Alzpk\LaravelChangeLog\Models\Traits\HasChangeLog;

Examples

Here are some examples of how to use the package.

Use the package

Bellow is an example of how to use the package inside your model.

namespace App\Models;

use Alzpk\LaravelChangeLog\Models\Traits\HasChangeLog;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    use HasChangeLog;
}

Show changes for a model

Bellow is an example of how to use the show changes method.

$product = Product::first();

$product->changes->each(function ($change) {
    dump($change);
});

Revert latest changes

Bellow is an example of how to use the revert latest changes method.

$product = Product::first();

$product->revertLatestChanges();

Revert changes by id

Bellow is an example of how to use the revert changes by id method.

$product = Product::first();

$change = $product->changes->first();

$product->revertChangesById($change->id);

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-24