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
2 parents 6cb7046 + 89653f7 commit b7ccf71
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ A tool to activity logger to monitor the users of your Laravel Nova.
- Behind the scenes [spatie/laravel-activitylog](https://github.com/spatie/laravel-activitylog) is used.



![screenshot](https://raw.githubusercontent.com/bolechen/nova-activitylog/master/docs/screenshot.png?20190308)


## Installation

You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:
Expand All @@ -28,26 +28,19 @@ php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProv
*Note*: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the format of the subject_id and causer_id fields in the published migration before continuing.



After publishing the migration you can create the `activity_log` table by running the migrations:

```bash
php artisan migrate
```



You can optionally publish the config file with:

```bash
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="config"
```



**You can find More `Activitylog` documentation on https://docs.spatie.be/laravel-activitylog/v3.**


## How to use

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

Expand All @@ -65,7 +58,25 @@ 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

Expand Down
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 b7ccf71

Please sign in to comment.