<?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('quality_checks', function (Blueprint $table) {
            $table->id();
            $table->foreignId('work_order_id')->nullable()->constrained();
            $table->foreignId('product_id')->constrained();
            $table->foreignId('inspector_id')->constrained('users');
            $table->decimal('checked_quantity', 15, 4);
            $table->decimal('passed_quantity', 15, 4);
            $table->decimal('failed_quantity', 15, 4)->default(0);
            $table->enum('status', ['pass', 'fail', 'conditional_pass'])->default('pass');
            $table->text('notes')->nullable();
            $table->timestamps();
        });
    }

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