<?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('jasa', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            // Jadikan nullable karena jika 'Antar ke Toko' user tidak perlu pilih alamat penjemputan
            $table->foreignId('address_id')->nullable()->constrained('addresses')->nullOnDelete();
            
            $table->string('merek_printer');
            $table->string('tipe_printer');
            $table->string('kategori_keluhan');
            $table->text('deskripsi_masalah');
            $table->string('foto_video_kondisi')->nullable(); 
            $table->enum('pernah_diservis', ['Iya', 'Tidak'])->default('Tidak');
            $table->enum('jenis_layanan', ['Antar ke Toko', 'Panggilan Teknisi'])->default('Antar ke Toko');
            $table->string('status')->default('pending');
            $table->timestamps();
        });
    }

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