2023_02_20_120328_create_audit_logs_table.php
1 <?php 2 3 use App\Models\User; 4 use Illuminate\Database\Migrations\Migration; 5 use Illuminate\Database\Schema\Blueprint; 6 use Illuminate\Support\Facades\Schema; 7 8 return new class extends Migration 9 { 10 /** 11 * Run the migrations. 12 * 13 * @return void 14 */ 15 public function up() 16 { 17 Schema::create('audit_logs', function (Blueprint $table) { 18 $table->ulid('id')->primary(); 19 $table->timestamp('created_at'); 20 $table->ipAddress('ip'); 21 $table->foreignIdFor(User::class); 22 $table->string('method')->nullable(); 23 $table->json('payload')->nullable(); 24 $table->string('route')->nullable(); 25 $table->string('event')->nullable(); 26 }); 27 } 28 29 /** 30 * Reverse the migrations. 31 * 32 * @return void 33 */ 34 public function down() 35 { 36 Schema::dropIfExists('audit_logs'); 37 } 38 };