diff --git a/app/Actions/ActivityService.php b/app/Actions/ActivityService.php index dce7dc7b2..b2a4a132f 100644 --- a/app/Actions/ActivityService.php +++ b/app/Actions/ActivityService.php @@ -11,6 +11,7 @@ use BookStack\Interfaces\Loggable; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Request; class ActivityService { @@ -58,6 +59,7 @@ class ActivityService return $this->activity->newInstance()->forceFill([ 'type' => strtolower($type), 'user_id' => user()->id, + 'ip' => Request::ip(), ]); } diff --git a/database/migrations/2021_08_21_044614_add_column_ip_into_activities.php b/database/migrations/2021_08_21_044614_add_column_ip_into_activities.php new file mode 100644 index 000000000..97cc2c039 --- /dev/null +++ b/database/migrations/2021_08_21_044614_add_column_ip_into_activities.php @@ -0,0 +1,35 @@ +string('ip', 45)->after('user_id'); + + $table->index(['ip'], 'user_ip_idx'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('activities', function (Blueprint $table) { + $table->dropIndex('user_ip_idx'); + $table->dropColumn('ip'); + }); + } +} diff --git a/resources/lang/en/settings.php b/resources/lang/en/settings.php index 4c1ae1345..d4feb2e7c 100755 --- a/resources/lang/en/settings.php +++ b/resources/lang/en/settings.php @@ -117,6 +117,7 @@ return [ 'audit_deleted_item' => 'Deleted Item', 'audit_deleted_item_name' => 'Name: :name', 'audit_table_user' => 'User', + 'audit_table_user_ip' => 'User IP', 'audit_table_event' => 'Event', 'audit_table_related' => 'Related Item or Detail', 'audit_table_date' => 'Activity Date', diff --git a/resources/views/settings/audit.blade.php b/resources/views/settings/audit.blade.php index 7a66cc3f3..b1de77567 100644 --- a/resources/views/settings/audit.blade.php +++ b/resources/views/settings/audit.blade.php @@ -62,6 +62,7 @@ {{ trans('settings.audit_table_event') }} {{ trans('settings.audit_table_related') }} + {{ trans('settings.audit_table_user_ip') }} {{ trans('settings.audit_table_date') }} @@ -88,6 +89,7 @@
{{ $activity->detail }}
@endif + {{ $activity->ip }} {{ $activity->created_at }} @endforeach