<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->id();

            $table->foreignId('customer_id')->constrained();
            $table->foreignId('contact_id')->nullable()->constrained();
            $table->foreignId('invoice_id')->nullable()->constrained();

            $table->string('internal_po')->nullable();
            $table->string('customer_po');
            $table->string('order_type');
            $table->date('order_date');
            $table->date('due_date');
            $table->string('status');
            $table->longText('notes')->nullable();

            $table->boolean('rush')->default(0);
            $table->boolean('repeat')->default(0);
            $table->boolean('new_art')->default(0);
            $table->boolean('event')->default(0);
            $table->boolean('digitizing')->default(0);
            $table->boolean('garments')->default(0);
            $table->boolean('supplied_file')->default(0);

            $table->boolean('printed')->default(0);
            $table->boolean('pre_production')->default(0);

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

    public function down(): void
    {
        Schema::dropIfExists('orders');
    }
};
