From e57ccb6a5507e0b121698c031acc2f0e736f41f4 Mon Sep 17 00:00:00 2001 From: Louis Jeckel Date: Mon, 7 Sep 2020 12:43:10 +0200 Subject: [PATCH] track sessions on access logs --- app/AccessLog.php | 2 ++ ...03413_add_session_data_to_activity_log.php | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 database/migrations/2020_09_07_103413_add_session_data_to_activity_log.php diff --git a/app/AccessLog.php b/app/AccessLog.php index a14b565..48ba350 100644 --- a/app/AccessLog.php +++ b/app/AccessLog.php @@ -14,6 +14,7 @@ use Illuminate\Http\Request; * @property string $user_agent; * @property User $user; * @property int $user_id; + * @property string $session_id * */ class AccessLog extends Model @@ -43,6 +44,7 @@ class AccessLog extends Model $entry->user_id = Auth::check() ? Auth::user()->id : null; $entry->user_agent = $request->userAgent(); $entry->file_id = $file ? $file->id : null; + $entry->session_id = \Session::getId(); $entry->save(); diff --git a/database/migrations/2020_09_07_103413_add_session_data_to_activity_log.php b/database/migrations/2020_09_07_103413_add_session_data_to_activity_log.php new file mode 100644 index 0000000..6e7d20b --- /dev/null +++ b/database/migrations/2020_09_07_103413_add_session_data_to_activity_log.php @@ -0,0 +1,32 @@ +text('session_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('access_logs', function (Blueprint $table) { + $table->dropColumn('session_id'); + }); + } +} -- 2.39.5