From 89653f7ede4c92994bc095c159063d829b1c292b Mon Sep 17 00:00:00 2001 From: Bole Chen Date: Wed, 13 Mar 2019 22:53:51 +0800 Subject: [PATCH] add How to use to README --- README.md | 22 ++++++++++++++++++++++ routes/api.php | 9 +++++++++ 2 files changed, 31 insertions(+) diff --git a/README.md b/README.md index 1029581..62f0c2a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/routes/api.php b/routes/api.php index 1b1b1cd..69e94e8 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,5 +1,14 @@ + * + * 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;