<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('payroll_pt_slabs', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_id')->nullable();
            $table->string('state', 100);
            $table->decimal('min_gross', 15, 2)->default(0);
            $table->decimal('max_gross', 15, 2)->nullable();
            $table->decimal('amount', 15, 2)->default(0);
            $table->date('effective_from')->nullable();
            $table->timestamps();

            $table->foreign('company_id')->references('id')->on('companies')->nullOnDelete();
            $table->index(['company_id', 'state']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('payroll_pt_slabs');
    }
};
