dataworkstr / revisionable
轻松管理您的MongoDB版本。
v5.3.9
2016-11-16 08:44 UTC
Requires
- php: >=5.4
- mongodb/mongodb: ^1.0.0
Requires (Dev)
- cartalyst/sentry: ~2.0
- illuminate/auth: 5.2.*
- illuminate/database: 5.2.*
- mockery/mockery: *
- phpspec/phpspec: ~2.0@dev
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ~2.0
- tymon/jwt-auth: ^0.5.3
This package is not auto-updated.
Last update: 2024-09-14 19:25:43 UTC
README
轻松管理您的MongoDB版本。
支持Lumen5 + MongoDB版本,支持文档模型
要求
- 此包需要PHP 5.4+
- MongoDB 3.0+
- 目前它与Laravel5 +通用Illuminate Guard,tymon/jwt-auth OR cartalyst/sentry 2/sentinel 2配合使用
使用(Laravel5基本示例 - 下文也有自定义说明)
1. 下载包或将其要求在 composer.json
"require": {
// for Lumen5+ use:
"dataworkstr/revisionable": "~1.0",
...
},
2. 将服务提供者添加到您的 app/config/app.php
'providers' => array( ... 'Sofa\Revisionable\Laravel\ServiceProvider', ),
3. 发布包配置文件
~$ php artisan vendor:publish [--provider="Sofa\Revisionable\Laravel\ServiceProvider"]
这将创建 config/sofa_revisionable.php
文件,您可以在其中调整一些设置
<?php return [ /* |-------------------------------------------------------------------------- | User provider (auth) implementation. |-------------------------------------------------------------------------- | | By default Laravel generic Illuminate\Auth\Guard. | | Supported options: | - illuminate | - sentry | - sentinel | - jwt-auth */ 'userprovider' => 'illuminate', /* |-------------------------------------------------------------------------- | User field to be saved as the author of tracked action. |-------------------------------------------------------------------------- | | By default: | | - id for illuminate | - login field (email) for sentry/sentinel | - id or ANY field in User model for tymon/jwt-auth */ 'userfield' => null, /* |-------------------------------------------------------------------------- | Table used for the revisions. |-------------------------------------------------------------------------- */ 'table' => 'revisions', /* |-------------------------------------------------------------------------- | Table max revision count / default=10 |-------------------------------------------------------------------------- */ 'options' => [ 'max_revision'=>10 ], ];
4. 运行迁移以创建版本表
~$ php artisan migrate [--database=custom_connection]
如果您希望迁移使用非默认数据库连接运行,可以提供额外的 --database
参数
5. 将版本特性合约添加到您希望跟踪的模型中
<?php namespace App; use Sofa\Revisionable\Laravel\RevisionableTrait; // trait use Sofa\Revisionable\Revisionable; // interface class User extends \Eloquent implements Revisionable { use RevisionableTrait; /* * Set revisionable whitelist - only changes to any * of these fields will be tracked during updates. */ protected $revisionable = [ 'email', 'name', 'phonenumber.main_phone.0' ];