From: Louis Jeckel Date: Mon, 7 Sep 2020 10:43:10 +0000 (+0200) Subject: track sessions on access logs X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e57ccb6a5507e0b121698c031acc2f0e736f41f4;p=psq.git track sessions on access logs --- 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'); + }); + } +}