Skip to content

Commit

Permalink
Move the activity model saving event listener into the booted callbac…
Browse files Browse the repository at this point in the history
…k to stop errors when the spatie activity log package is booted after this package (#12)
  • Loading branch information
joeyrush authored and bolechen committed Nov 6, 2019
1 parent 72771a4 commit e3547ad
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ToolServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public function boot()

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

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

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

Nova::resources([
config('nova-activitylog.resource'),
]);
Expand Down

0 comments on commit e3547ad

Please sign in to comment.