feat: implement system-wide activity logging with database persistence, repository patterns, and admin controller access.

This commit is contained in:
pbao9
2026-05-16 20:01:52 +07:00
parent 8a115c5175
commit 551c90d60b
44 changed files with 845 additions and 33 deletions
@@ -0,0 +1,33 @@
<?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('activity_logs', function (Blueprint $table) {
$table->id();
$table->string('log_name', 100)->index();
$table->string('event', 30)->index();
$table->text('description');
$table->string('subject_type', 150)->nullable()->index();
$table->string('subject_id', 100)->nullable()->index();
$table->string('causer_type', 20)->nullable()->index(); // admin | customer | system
$table->unsignedBigInteger('causer_id')->nullable()->index();
$table->string('causer_name', 150)->nullable();
$table->json('old_values')->nullable();
$table->json('new_values')->nullable();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->timestamp('created_at')->useCurrent()->index();
});
}
public function down(): void
{
Schema::dropIfExists('activity_logs');
}
};