<?php

use App\Enums\OfficeTypes;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('offices', function (Blueprint $table) {
            $table->id();
            $table->string('logo')->nullable();
            $table->string('dark_logo')->nullable();
            $table->enum('type', OfficeTypes::values())->default('agent');
            $table->string('name', 100);
            $table->string('code')->unique();
            $table->string('address', 200);
            $table->foreignId('city_id')->nullable()->constrained()->nullOnDelete();
            $table->foreignId('state_id')->nullable()->constrained()->nullOnDelete();
            $table->foreignId('country_id')->nullable()->constrained()->nullOnDelete();
            $table->string('post_code', 20)->nullable();
            $table->string('website', 100)->nullable();
            $table->string('primary_email', 100)->nullable();
            $table->string('tel', 100)->nullable();
            $table->string('mobile', 100)->nullable();
            $table->foreignId('comapany_admin')->nullable()->constrained('office_users')->nullOnDelete();
            $table->text('note')->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

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