<?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('orders', function (Blueprint $table) {
            $table->id();

            // user_id nullable, user delete হলে order ডিলিট না হয়ে user_id null হবে
            $table->foreignId('user_id')
                ->nullable()
                ->constrained()
                ->nullOnDelete();

            $table->string('phone');
            $table->string('name');
            $table->string('address');

            // মোট অর্ডার ভ্যালু (subtotal + shipping - discount ইত্যাদি)
            $table->decimal('total_price', 10, 2);

            $table->enum('status', ['pending', 'on-hold', 'completed', 'cancelled'])
                ->default('pending')
                ->comment('pending, on-hold, completed, cancelled');

            $table->timestamps();
        });
    }

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