From c1de4778d8eaa184f77e54a6dcacf57263f69823 Mon Sep 17 00:00:00 2001 From: Dipesh79 Date: Tue, 23 Jan 2024 17:58:31 +0545 Subject: [PATCH] fix: fixed migration file and update function --- databases/migrations/update_logs_table.php.stub | 11 +++++++---- src/Traits/HasLog.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/databases/migrations/update_logs_table.php.stub b/databases/migrations/update_logs_table.php.stub index 993466e..267312b 100644 --- a/databases/migrations/update_logs_table.php.stub +++ b/databases/migrations/update_logs_table.php.stub @@ -4,14 +4,14 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateUserActivityLogTable extends Migration +return new class extends Migration { /** * Run the migrations. */ public function up(): void { - Schema::create('user_activity_logs', function (Blueprint $table) { + Schema::table('user_activity_logs', function (Blueprint $table) { $table->json('old_data')->nullable(); $table->json('changed_values')->nullable(); }); @@ -22,7 +22,10 @@ class CreateUserActivityLogTable extends Migration */ public function down(): void { - Schema::dropColumn('old_data'); - Schema::dropColumn('new_data'); + Schema::table('user_activity_logs', function (Blueprint $table) { + $table->dropColumn('old_data'); + $table->dropColumn('changed_values'); + }); + } }; diff --git a/src/Traits/HasLog.php b/src/Traits/HasLog.php index 32a5c11..f184bf1 100644 --- a/src/Traits/HasLog.php +++ b/src/Traits/HasLog.php @@ -47,7 +47,7 @@ public static function boot() 'ip_address' => request()->ip(), 'device' => request()->userAgent(), 'user_id' => auth()->user()->id, - 'old_values' => json_encode($model->getRawOriginal()), + 'old_data' => json_encode($model->getRawOriginal()), 'changed_values' => json_encode($model->getChanges()) ]); });