feat: Implement value change logging functionality with models, traits, and migration; add tests for logging behavior and value change mapping

This commit is contained in:
2026-08-03 15:43:50 -03:00
parent 3b2977a330
commit c4b317d5fc
6 changed files with 307 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('value_changes', function (Blueprint $table): void {
$table->id();
$table->morphs('trackable');
$table->string('attribute');
$table->text('old_value')->nullable();
$table->text('new_value')->nullable();
$table->timestamp('changed_at');
$table->string('actor_type');
$table->foreignId('user_id')
->nullable()
->constrained('users')
->cascadeOnUpdate()
->nullOnDelete();
});
}
public function down(): void
{
Schema::dropIfExists('value_changes');
}
};