<?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('ordenes_servicio', function (Blueprint $table) {
            $table->id();
            $table->string('numero_orden')->unique();
            $table->foreignId('cliente_id')->constrained('clientes');
            $table->foreignId('marca_celular_id')->nullable()->constrained('marcas_celular');
            $table->foreignId('referencia_celular_id')->nullable()->constrained('referencias_celular');
            $table->string('imei')->nullable();
            $table->enum('condicion_ingreso', ['Bueno', 'Regular', 'Malo'])->default('Regular');
            $table->text('descripcion_falla');
            $table->text('observaciones_fisicas')->nullable();
            $table->decimal('precio_diagnostico', 12, 2)->default(0);
            $table->decimal('precio_reparacion', 12, 2)->default(0);
            $table->enum('estado', ['Recibido', 'Diagnostico', 'En reparacion', 'Listo', 'Entregado'])->default('Recibido');
            $table->date('fecha_estimada_entrega')->nullable();
            $table->string('usuario')->nullable();
            $table->tinyInteger('activo')->default(1);
            $table->timestamps();
        });
    }

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