Skip to content

Commit

Permalink
add How to use to README
Browse files Browse the repository at this point in the history
  • Loading branch information
bolechen committed Mar 13, 2019
1 parent 2cc86f9 commit 89653f7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ You can install the package in to a Laravel app that uses [Nova](https://nova.la
composer require bolechen/nova-activitylog
```

## How to use

Next up, you must register the tool with Nova. This is typically done in the `tools` method of the `NovaServiceProvider`.

```php
Expand All @@ -30,6 +32,26 @@ public function tools()
}
```

Because backend we use the `spatie/laravel-activitylog` package, you need to do is let your model use the `Spatie\Activitylog\Traits\LogsActivity` trait.

Here's an example:

```php
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;

class NewsItem extends Model
{
use LogsActivity;

protected $fillable = ['name', 'text'];

protected static $logAttributes = ['name', 'text'];
}
```

For more advanced usage can look at the doc: https://docs.spatie.be/laravel-activitylog/v3/advanced-usage/logging-model-events

## License

The MIT License (MIT). Please see [License File](LICENSE) for more information.
9 changes: 9 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the bolechen/nova-activitylog
*
* (c) Bole Chen <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Expand Down

0 comments on commit 89653f7

Please sign in to comment.