Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit 96ac618

Browse files
committed
[ci skip] Documented.
1 parent 6fa8b77 commit 96ac618

File tree

3 files changed

+70
-11
lines changed

3 files changed

+70
-11
lines changed

CHANGELOG.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Very short description of the package
1+
# Notification Driver por [Laravel Auditing](http://laravel-auditing.com) ^8.0
22

33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/andreshg112/laravel-auditing-notifications.svg?style=flat-square)](https://packagist.org/packages/andreshg112/laravel-auditing-notifications)
44
[![Build Status](https://travis-ci.com/andreshg112/laravel-auditing-notifications.svg?branch=master)](https://travis-ci.com/andreshg112/laravel-auditing-notifications)
@@ -7,22 +7,86 @@
77
[![Code Coverage](https://scrutinizer-ci.com/g/andreshg112/laravel-auditing-notifications/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/andreshg112/laravel-auditing-notifications/?branch=master)
88
[![Total Downloads](https://img.shields.io/packagist/dt/andreshg112/laravel-auditing-notifications.svg?style=flat-square)](https://packagist.org/packages/andreshg112/laravel-auditing-notifications)
99

10-
This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.
10+
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](https://github.com/lab123it/aws-sns).
11+
12+
## Use case
13+
14+
If you have some microservices and want to have centralized auditing, this could be helpful.
1115

1216
## Installation
1317

18+
### Step 1
19+
1420
You can install the package via composer:
1521

1622
```bash
1723
composer require andreshg112/laravel-auditing-notifications
1824
```
1925

26+
> This package depends on [owen-it/laravel-auditing ^8.0](https://github.com/owen-it/laravel-auditing) and [lab123it/aws-sns](https://github.com/lab123it/aws-sns), so you have to configure them first in order to make this work.
27+
28+
### Step 2
29+
30+
Change the audit default driver:
31+
32+
```php
33+
return [
34+
// ...
35+
/*
36+
|--------------------------------------------------------------------------
37+
| Audit Driver
38+
|--------------------------------------------------------------------------
39+
|
40+
| The default audit driver used to keep track of changes.
41+
|
42+
*/
43+
44+
'driver' => Andreshg112\LaravelAuditingNotifications\NotificationDriver::class,
45+
];
46+
```
47+
48+
> You can make this locally on a model. Please see the documentation: http://laravel-auditing.com/docs/8.0/audit-drivers.
49+
50+
### Step 3
51+
52+
In your `config/audit.php` file, add this:
53+
54+
```php
55+
return [
56+
// ...
57+
58+
// andreshg112/laravel-auditing-notifications
59+
60+
'notification-driver' => [
61+
// Required if you're going to use different notifications channels for sending audit data.
62+
'notifications' => [
63+
Andreshg112\LaravelAuditingNotifications\AuditSns::class,
64+
],
65+
66+
// Required if you're going to use the default Andreshg112\LaravelAuditingNotifications\AuditSns Notification.
67+
'sns' => [
68+
'topic_arn' => 'arn:aws:sns:us-east-1:xxxxxxxxxxxx:auditing-notifications',
69+
],
70+
],
71+
];
72+
```
73+
2074
## Usage
2175

76+
Add the `Illuminate\Notifications\Notifiable` trait to the models you want to audit, besides Auditable contract and trait.
77+
2278
```php
23-
// Usage description here
79+
use Illuminate\Database\Eloquent\Model;
80+
use Illuminate\Notifications\Notifiable;
81+
82+
class Vehicle extends Model implements \OwenIt\Auditing\Contracts\Auditable
83+
{
84+
use \OwenIt\Auditing\Auditable, Notifiable;
85+
}
2486
```
2587

88+
That's all! Just execute an [auditable event](http://laravel-auditing.com/docs/8.0/audit-events) over the model in order to send a notification.
89+
2690
### Testing
2791

2892
```bash
@@ -31,7 +95,7 @@ composer test
3195

3296
### Changelog
3397

34-
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
98+
Please see [Releases](../../releases) for more information what has changed recently.
3599

36100
## Contributing
37101

tests/NotificationDriverTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ protected function resolveUrl(): string
6161

6262
protected function resolveUser()
6363
{
64+
//
6465
}
6566

6667
protected function resolveUserAgent()
6768
{
69+
//
6870
}
6971
}

0 commit comments

Comments
 (0)