Notification Driver for Laravel Auditing ^8.0
Latest Version on Packagist Build Status StyleCI Scrutinizer Code Quality Code Coverage Total Downloads
This package allows you to send notifications with audit data instead of saving it to an accessible database. By default, it sends notifications through AWS SNS using the package lab123it/aws-sns.
If you have some microservices and want to have centralized auditing, this could be helpful.
- PHP >= 7.1
- Laravel >= 5.2 && < 5.8
This package depends on owen-it/laravel-auditing:^8.0 and lab123it/aws-sns:dev-master, so you have to install and configure them first in order to make this work.
You can install the package via composer:
composer require andreshg112/laravel-auditing-notifications
Change the audit default driver:
return [ // ... /* |-------------------------------------------------------------------------- | Audit Driver |-------------------------------------------------------------------------- | | The default audit driver used to keep track of changes. | */ 'driver' => Andreshg112\LaravelAuditingNotifications\NotificationDriver::class, ];
You can make this locally on a model. Please see the documentation: http://laravel-auditing.com/docs/8.0/audit-drivers.
In your config/audit.php file, add this:
return [ // ... // andreshg112/laravel-auditing-notifications 'notification-driver' => [ // Required if you're going to use different notifications channels for sending audit data. 'notifications' => [ Andreshg112\LaravelAuditingNotifications\AuditSns::class, // Or this if you want to queue the delivery of the message. // https://laravel.com/docs/5.2/queues // Andreshg112\LaravelAuditingNotifications\AuditSnsQueue::class, ], // Required if you're going to use the default Andreshg112\LaravelAuditingNotifications\AuditSns Notification. 'sns' => [ 'topic_arn' => 'arn:aws:sns:us-east-1:xxxxxxxxxxxx:auditing-notifications', ], ], ];
Add the Illuminate\Notifications\Notifiable trait to the models you want to audit, besides Auditable contract and trait.
use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; class Vehicle extends Model implements \OwenIt\Auditing\Contracts\Auditable { use \OwenIt\Auditing\Auditable, Notifiable; }
That's all! Just execute an auditable event over the model in order to send a notification.
composer testPlease see Releases for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email andreshg112@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.