<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up()
    {
        Schema::create('delivery_men', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('phone')->unique();
            $table->string('email')->nullable();
            $table->string('photo')->nullable();
            $table->string('vehicle_type')->nullable(); // bike, van, etc.
            $table->string('vehicle_number')->nullable();
            $table->enum('status', ['active', 'inactive'])->default('active');
            $table->timestamps();
        });

        // Add delivery_man_id to shippings table
        Schema::table('shippings', function (Blueprint $table) {
            $table->unsignedBigInteger('delivery_man_id')->nullable()->after('map');
        });
    }

    public function down()
    {
        Schema::table('shippings', function (Blueprint $table) {
            $table->dropColumn('delivery_man_id');
        });
        Schema::dropIfExists('delivery_men');
    }
};
