<?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('vehicle_inspections', function (Blueprint $table) {
            $table->id();
            $table->foreignId('service_order_id')->constrained()->onDelete('cascade');
            $table->foreignId('vehicle_id')->constrained()->onDelete('cascade');
            $table->foreignId('technician_id')->constrained()->onDelete('cascade');
            $table->integer('current_mileage');
            $table->json('inspection_checklist'); // flexible JSON structure for inspection items
            $table->json('photos')->nullable(); // array of photo URLs/paths
            $table->json('videos')->nullable(); // array of video URLs/paths
            $table->text('overall_condition');
            $table->json('recommendations')->nullable(); // array of recommended services
            $table->enum('priority_level', ['low', 'medium', 'high', 'urgent'])->default('medium');
            $table->text('customer_communication')->nullable();
            $table->boolean('customer_approved')->default(false);
            $table->datetime('inspection_date');
            $table->timestamps();
        });
    }

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