<?php
namespace App\Traits;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
trait MigrationTrait
{

    public function systemTrackingUp()
    {
        Schema::create('system_tracking', function (Blueprint $table) {
            $table->id();
            $table->integer('auth_user_id')->nullable();
            $table->string('route_name')->nullable();
            $table->string('ip_address')->nullable();
            $table->string('method')->nullable();
            $table->string('uri')->nullable();
            $table->json('user')->nullable();
            $table->longText('header')->nullable();
            $table->longText('request_body')->nullable();
            $table->string('url')->nullable();
            $table->timestamps();
        });
    }

    public function systemTrackingDown()
    {
        Schema::dropIfExists('system_tracking');
    }

    public function userRoleMasterUp()
    {
        Schema::create('roles', function (Blueprint $table) {

            $table->id();
            $table->string('name');
            $table->integer('created_by')->default(0);
            $table->boolean('status')->default(true);
            $table->boolean('is_delete')->default(false);
            $table->timestamps();
        });
    }
    public function userRoleMasterDown()
    {
        Schema::dropIfExists('roles');
    }

    public function fileCategoryUp()
    {
        Schema::create('file_category', function (Blueprint $table) {

            $table->id();
            $table->string('name');
            $table->string('file_name_prefix');
            $table->timestamps();
        });
    }
    public function fileCategoryDown()
    {
        Schema::dropIfExists('file_category');
    }
    public function fileStagingUp()
    {
        Schema::create('file_staging', function (Blueprint $table) {

            $table->id();
            $table->integer('uploaded_by');
            $table->string('original_name');
            $table->string('upload_name')->nullable();
            $table->string('file_extension');
            $table->string('mime_type');
            $table->string('file_size')->nullable();
            $table->integer('file_cat_id');
            $table->boolean('is_uploaded')->default(false);
            $table->boolean('status')->default(true);
            $table->boolean('is_delete')->default(false);
            $table->timestamps();
        });
    }
    public function fileStagingDown()
    {
        Schema::dropIfExists('file_staging');
    }

}
