<?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('labors', function (Blueprint $t) {
            $t->id();
            $t->foreignId('company_id')->constrained()->cascadeOnDelete();

            $t->string('category');                  // Motor / Frâne / Suspensie / ...
            $t->string('name_ro');                   // numele manoperei (ro)
            $t->string('name_ru')->nullable();
            $t->string('code', 32)->nullable();      // cod intern opțional

            $t->decimal('hours', 5, 2)->default(1);  // norma-oră
            $t->decimal('price', 10, 2)->default(0); // preț calculat (hours * tarif companie de obicei)
            $t->boolean('is_active')->default(true);
            $t->text('notes')->nullable();

            $t->timestamps();
            $t->softDeletes();

            $t->index(['company_id', 'category']);
            $t->index(['company_id', 'is_active']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('labors');
    }
};
