diff --git a/README.md b/README.md index b38853a..ebd4ae4 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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`. @@ -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 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;