hnhdigital-os/laravel-model-change-tracking 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

hnhdigital-os/laravel-model-change-tracking

Composer 安装命令:

composer require hnhdigital-os/laravel-model-change-tracking

包简介

Provides support for tracking current user against model changes for the Eloquent ORM

README 文档

README

This package provides a number of traits to track changes made to a model.

Latest Stable Version Total Downloads Latest Unstable Version License

Build Status StyleCI Test Coverage Issue Count Code Climate

Install

Via composer:

$ composer require hnhdigital-os/laravel-model-change-tracking ~1.0

This package's service provider will autoload from Laravel 5.5.

To enable the service provider in versions prior to Laravel 5.4, edit the config/app.php:

    'providers' => [
        ...
        Bluora\LaravelModelChangeTracking\ServiceProvider::class,
        ...
    ];

State Change

Track state changes on your model and by which user for the following states - created, updated, deleted, and restored.

Attribute Change Trait

Adds a saving event to the model to track changes to all attribute values.

Change by User Trait

Adds events to set a attribute to the current user for when a model is created, updated, archived, or deleted.

Usage

User tracking of changes.

Add a created_by, updated_by, archived_by, and deleted_by attributes to your model's database table.

namespace App\Models;

use Bluora\LaravelModelChangeTracking\ChangeByUserTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use ChangeByUserTrait;
}

Turn off tracking attribute

You can turn off by returning false.

public function getCreatedByColumn()
{
    return false;
}

public function getUpdatedByColumn()
{
    return false;
}

public function getArchivedByColumn()
{
    return false;
}

public function getDeletedByColumn()
{
    return false;
}

Different attribute name

You can specify the attribute name in the return value.

public function getCreatedByColumn()
{
    return 'created_by';
}

public function getUpdatedByColumn()
{
    return 'updated_by';
}

public function getArchivedByColumn()
{
    return 'updated_by';
}

public function getDeletedByColumn()
{
    return 'deleted_by';
}

Track state changes of models

Tracks model state changes externally in database table.

namespace App\Models;

use Bluora\LaravelModelChangeTracking\LogStateChangeTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use LogStateChangeTrait;
}

Log each attribute value change

Tracks attribute value changes.

namespace App\Models;

use Bluora\LaravelModelChangeTracking\LogChangeTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    use LogChangeTrait;

    protected $do_not_log = [
        'password',
        'remember_token',
    ];
}

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固