<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_activity_logs', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('user_id')->nullable()->index('user_activity_logs_user_id_foreign');
            $table->string('username', 100)->nullable();
            $table->string('user_name', 100)->nullable();
            $table->string('user_first_name', 100)->nullable();
            $table->string('user_last_name', 100)->nullable();
            $table->string('position', 100)->nullable();
            $table->string('mobile', 20)->nullable();
            $table->integer('province_id')->nullable();
            $table->string('province_fa', 100)->nullable();
            $table->integer('city_id')->nullable();
            $table->string('city_fa', 100)->nullable();
            $table->string('method', 20)->nullable();
            $table->string('agent', 200)->nullable();
            $table->string('ip', 30)->nullable();
            $table->text('url')->nullable();
            $table->text('query_parameter')->nullable();
            $table->string('log_unique_code', 100)->nullable();
            $table->string('description', 300);
            $table->string('action_type', 100)->nullable();
            $table->text('model')->nullable();
            $table->timestamps();
            $table->integer('mm')->nullable()->storedAs('month(`created_at`)');
            $table->integer('yy')->nullable()->storedAs('year(`created_at`)');
            $table->integer('dd')->nullable()->storedAs('dayofmonth(`created_at`)');
            $table->integer('hh')->nullable()->storedAs('hour(`created_at`)');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_activity_logs');
    }
};
