Merge branch 'log-ip-address' of https://github.com/johnroyer/BookStack into johnroyer-log-ip-address

This commit is contained in:
Dan Brown 2021-09-26 16:17:28 +01:00
commit 8972f7b212
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
4 changed files with 40 additions and 0 deletions

View File

@ -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(),
]);
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddColumnIpIntoActivities extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('activities', function (Blueprint $table) {
$table->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');
});
}
}

View File

@ -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',

View File

@ -62,6 +62,7 @@
<a href="{{ sortUrl('/settings/audit', $listDetails, ['sort' => 'key']) }}">{{ trans('settings.audit_table_event') }}</a>
</th>
<th>{{ trans('settings.audit_table_related') }}</th>
<th>{{ trans('settings.audit_table_user_ip') }}</th>
<th>
<a href="{{ sortUrl('/settings/audit', $listDetails, ['sort' => 'created_at']) }}">{{ trans('settings.audit_table_date') }}</a></th>
</tr>
@ -88,6 +89,7 @@
<div class="px-m">{{ $activity->detail }}</div>
@endif
</td>
<td>{{ $activity->ip }}</td>
<td>{{ $activity->created_at }}</td>
</tr>
@endforeach