定制 rs/laravel-version-control 二次开发

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

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

rs/laravel-version-control

最新稳定版本:v1.1.0

Composer 安装命令:

composer require rs/laravel-version-control

包简介

Foundations for making your app version controlled. Provides migration, blueprint and base models. Will make your app GxP compliant if you exclusively use the VC models and table structure as set out in this package.

README 文档

README

This package provides base models to use to make your app Version Control. It will also meet GxP compliance requirements.

Installation

composer require rs/laravel-version-control

If you wish to adjust the installation you can publish the assets

php artisan vendor:publish to see publishing options, choose the appropriate option to publish this packages assets.

Migrations

You should setup your migrations to follow the migrations as seen in the tests/Fixtures/database/migrations files. For each model 2 tables will be created, the key (normal) table and the version history table.

Example migration

use Redsnapper\LaravelVersionControl\Database\Blueprint;
use Redsnapper\LaravelVersionControl\Database\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $this->makeVcTables("users",function(Blueprint $table){
            $table->string('email')->unique();
            $table->string('password');
        },function(Blueprint $table){
            $table->string('email');
            $table->string('password');
        });
    }
}

Note we are using are own custom Migration and Blueprint class. This will create 2 tables: The users table and a corresponding users_versions table. The 3rd parameter is optional and will fallback to the fields in the second parameter.

Version Control Models

Each model you create should extend the Redsnapper\LaravelVersionControl\Models\BaseModel

use Redsnapper\LaravelVersionControl\Models\BaseModel;

class Post extends BaseModel
{
}

'Pivot' tables

Pivot table records are never destroyed. On creation they persist as records for the lifecycle of the project. Instead whenever a record is detached an active flag is switched to false.

Versions relationship

Versions can be accessed from models using the versions relationship.

$model->versions();

Anonymize

To anonymize any field for any model pass an array of the fields to be anonymized as below.

$model->anonymize(['email'=>'anon@example.com']);

This will create a new version for the action and will anonymize the fields passed. This will anonymize all versions attached to this model.

统计信息

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

GitHub 信息

  • Stars: 122
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2021-02-26