revisionable maintained by dataworkstr
Nice and easy way to handle revisions of your MongoDB.
*Lumen5 + MongoDB revisions *Support Document Model
- This package requires PHP 5.4+
- MongoDB 3.0+
- Currently it works out of the box with Laravel5 + generic Illuminate Guard, tymon/jwt-auth OR cartalyst/sentry 2/sentinel 2
"require": {
// for Lumen5+ use:
"dataworkstr/revisionable": "~1.0",
...
},
'providers' => array(
...
'Sofa\Revisionable\Laravel\ServiceProvider',
),
~$ php artisan vendor:publish [--provider="Sofa\Revisionable\Laravel\ServiceProvider"]
this will create config/sofa_revisionable.php
file, where you can adjust a few settings:
<?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
],
];
~$ php artisan migrate [--database=custom_connection]
You can provide additional --database
param if you want the migration to be run using non-default db connection.
<?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'
];