Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bolechen committed Nov 4, 2019
2 parents 5867bd6 + 42a9eb2 commit cc9ccd6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Next up, publish the config file with:
php artisan vendor:publish --provider="Bolechen\\NovaActivitylog\\ToolServiceProvider" --tag="config"
```

And change the resourceName in `config/nova-activitylog.log` to your customize resource name.
And change the `resource` in `config/nova-activitylog.php` to your custom nova resource.

## License

Expand Down
4 changes: 2 additions & 2 deletions config/nova-activitylog.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

return [
/*
* Set the resource used for `nova-activitylog` package. Default is `activitylogs`.
* Set the resource used for `nova-activitylog` package.
*/
'resourceName' => 'activitylogs',
'resource' => \Bolechen\NovaActivitylog\Resources\Activitylog::class,
];
2 changes: 1 addition & 1 deletion resources/views/navigation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:to="{
name: 'index',
params: {
resourceName: '{{ config('nova-activitylog.resourceName', 'activitylogs') }}'
resourceName: '{{ config('nova-activitylog.resource')::uriKey() }}'
}
}"
tag="h3"
Expand Down
15 changes: 8 additions & 7 deletions src/ToolServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Bolechen\NovaActivitylog;

use Bolechen\NovaActivitylog\Resources\Activitylog;
use Illuminate\Support\ServiceProvider;
use Laravel\Nova\Events\ServingNova;
use Laravel\Nova\Nova;
Expand All @@ -24,28 +23,30 @@ class ToolServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->publishes([
__DIR__.'/../config/nova-activitylog.php' => config_path('nova-activitylog.php'),
], 'config');

$this->mergeConfigFrom(__DIR__.'/../config/nova-activitylog.php', 'nova-activitylog');

$this->loadViewsFrom(__DIR__.'/../resources/views', 'nova-activitylog');

// 记录操作者 IP
// @see https://github.com/spatie/laravel-activitylog/issues/39
Activity::saving(function (Activity $activity) {
config('activitylog.activity_model')::saving(function (Activity $activity) {
$activity->properties = $activity->properties->put('ip', request()->ip());
});

$this->app->booted(function () {
Nova::resources([
Activitylog::class,
config('nova-activitylog.resource'),
]);
$this->routes();
});

Nova::serving(function (ServingNova $event) {
activity()->enableLogging();
});

$this->publishes([
__DIR__.'/../config/nova-activitylog.php' => config_path('nova-activitylog.php'),
], 'config');
}

/**
Expand Down

0 comments on commit cc9ccd6

Please sign in to comment.