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

Commit 41513c6

Browse files
committed
ReadMe: ElasticSearchAuditable
1 parent 251b699 commit 41513c6

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ For detailed description and all available options run `php artisan help [comman
8686

8787
## Usage
8888

89-
You can use the driver in any Auditable model like so:
89+
You can use the ElasticSearch driver in any Auditable model like so in order to store audit records in elasticsearch:
9090

9191
```
9292
<?php
@@ -112,6 +112,44 @@ class SomeModel extends Model implements AuditableContract
112112
}
113113
```
114114

115+
You can use the ElasticSearchAuditable trait in any Auditable model like so in order to retrieving Retrieving audit records records from elasticsearch:
116+
117+
```
118+
<?php
119+
namespace App\Models;
120+
121+
use Iconscout\Auditing\Drivers\ElasticSearch;
122+
use Iconscout\Auditing\Traits\ElasticSearchAuditable;
123+
use Illuminate\Database\Eloquent\Model;
124+
use OwenIt\Auditing\Auditable;
125+
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
126+
127+
class SomeModel extends Model implements AuditableContract
128+
{
129+
use Auditable, ElasticSearchAuditable;
130+
131+
/**
132+
* ElasticSearch Audit Driver
133+
*
134+
* @var Iconscout\Auditing\Drivers\ElasticSearch
135+
*/
136+
protected $auditDriver = ElasticSearch::class;
137+
138+
// ...
139+
}
140+
```
141+
142+
```
143+
// Get first available Icon
144+
$icon = Icon::first();
145+
146+
// Get all associated Audits
147+
$all = $icon->esAudits;
148+
149+
// Get all associated Audits via parameters ($page & $perPage)
150+
$all = $icon->esAudits($page = 1, $perPage = 10);
151+
```
152+
115153
## Donate
116154

117155
:coffee: If you like my package, it'd be nice of you [to buy me a cup of coffee](https://www.paypal.me/rankarpan).

0 commit comments

Comments
 (0)