<?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();
            $table->unsignedInteger('year');
            $table->string('name');
            $table->foreignId('user_id')->constrained('users')->restrictOnDelete();                 // менеджер
            $table->foreignId('district_id')->constrained('districts')->restrictOnDelete();         // округ
            $table->foreignId('area_id')->constrained('areas')->restrictOnDelete();                 // район
            $table->string('object_address');                                                            // адрес объекта
            $table->foreignId('object_type_id')->constrained('object_types')->restrictOnDelete();   // тип объекта
            $table->date('contract_date')->nullable();                                          // дата договора
            $table->string('contract_number')->nullable();                                      // номер дог-ра
            $table->text('comment')->nullable();                                                // комментарий
            $table->date('installation_date')->nullable();                                      // дата монтажа
            $table->date('ready_date')->nullable();                                             // дата готовности площадки
            $table->foreignId('brigadier_id')->nullable()->constrained('users')->restrictOnDelete(); // бригадир
            $table->foreignId('order_status_id')->constrained('order_statuses')->restrictOnDelete(); // статус объекта
            $table->string('tg_group_name')->nullable();
            $table->string('tg_group_link')->nullable();
            $table->string('ready_to_mount')->default('Нет');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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