<?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('deliveries', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('cliente_id')->constrained('users')->cascadeOnDelete();
            $table->foreignUuid('entregador_id')->nullable()->constrained('users')->nullOnDelete();
            $table->string('categoria');
            $table->string('origem');
            $table->string('destino');
            $table->text('descricao')->nullable();
            $table->decimal('preco_estimado', 10, 2);
            $table->enum('status', [
                'pendente',
                'aceite',
                'em_recolha',
                'recolhido',
                'em_transito',
                'entregue',
                'cancelado',
            ])->default('pendente');
            $table->timestamps();
        });
    }

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