Package Data | |
---|---|
Maintainer Username: | mintbridge |
Maintainer Contact: | paul.dixon@mintbridge.co.uk (Paul Dixon) |
Package Create Date: | 2015-12-06 |
Package Last Update: | 2017-01-25 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:21:34 |
Package Statistics | |
---|---|
Total Downloads: | 3,981 |
Monthly Downloads: | 48 |
Daily Downloads: | 3 |
Total Stars: | 2 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This Laravel 5 package allows model events to be logged to a database. It provides a trait that can be added to any Eloquent model allowing for chosen events to be logged using a polymorphic relationship.
This package can be installed through Composer.
composer require mintbridge/eloquent-auditing
Once installed add the service provider and facade to your app config
// config/app.php
'providers' => [
'...',
Mintbridge\EloquentAuditing\AuditServiceProvider::class,
];
'aliases' => [
...
'Auditor' => Mintbridge\EloquentAuditing\AuditorFacade::class,
];
You'll also need to publish and run the migration in order to create the database table.
php artisan vendor:publish --provider="Mintbridge\EloquentAuditing\AuditServiceProvider" --tag="config"
php artisan vendor:publish --provider="Mintbridge\EloquentAuditing\AuditServiceProvider" --tag="migrations"
php artisan migrate
The configuration will be written to config/auditing.php
. The options have sensible defaults but you should change the user to match the one used in your application.
This package will record the events from your models. To do so your model must use the Auditable
trait and implement AuditableInterface
.
use Mintbridge\EloquentAuditing\Auditable;
use Mintbridge\EloquentAuditing\AuditableInterface;
class Article extends Eloquent implements AuditableInterface {
use Auditable;
...
The trait by default will use the event in config/auditing.php
but you can overide this on a per model basis by adding a static $auditableEvents
array of event names to the model. See http://laravel.com/docs/5.1/eloquent#events for the available events.
use Mintbridge\EloquentAuditing\Auditable;
use Mintbridge\EloquentAuditing\AuditableInterface;
class Article extends Eloquent implements AuditableInterface {
use Auditable;
public static $auditableEvents = [
'creating',
'created',
'updating',
//...
];
...
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.