<?php
/*=========================================================================================
    App Name  : PPID PTUN Kupang
    File Name : activity_log
    --------------------------------------------------------------------------------------
    Author    : Fuad Auliya Rohman
    Email     : fuad.dev16@gmail.com
==========================================================================================*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    protected $table = 'activity_logs';
    /**a
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->id();
            $table->string('method', 20)->nullable();
            $table->string('type', 100)->nullable();
            $table->string('table', 100)->nullable();
            $table->string('guard_name', 20)->nullable();
            $table->string('activity');
            $table->json('new_value')->nullable();
            $table->json('old_value')->nullable();
            $table->ipAddress('ip_address', 50)->nullable();
            $table->string('agent', 50)->nullable();

            $table->bigInteger('causer_id')->nullable()->unsigned();
            $table->foreign('causer_id')->references('id')->on('users')->onDelete('restrict')->onUpdate('cascade');

            $table->timestamp('created_at');
        });
    }

    /**s
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->table);
    }
};
