Skip to content

Commit

Permalink
fix: fixed migration file and update function
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipesh79 committed Jan 23, 2024
1 parent ffdf896 commit c1de477
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions databases/migrations/update_logs_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand All @@ -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');
});

}
};
2 changes: 1 addition & 1 deletion src/Traits/HasLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
]);
});
Expand Down

0 comments on commit c1de477

Please sign in to comment.