<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('management_submissions', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained('users');
            $table->enum('status', ['Waiting for Approval', 'Approved', 'Rejected'])->default('Waiting for Approval');
            $table->integer('visit_dealer')->default(0);
            $table->integer('visit_retailer')->default(0);
            $table->integer('visit_farmer')->default(0);
            $table->foreignId('by')->nullable()->constrained('users');
            $table->text('note_by')->nullable();
            $table->timestamp('by_at')->nullable();
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();

        });
    }

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

