<?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
    {
        if (Schema::hasTable('companies')) {
            return;
        }
        Schema::create('companies', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('short_name')->nullable();
            $table->string('email')->nullable();
            $table->string('phone')->nullable();
            $table->string('website')->nullable();
            $table->string('address', 1000)->nullable();
            $table->string('app_layout', 10)->default('sidebar');
            $table->unsignedBigInteger('currency_id')->nullable();
            $table->unsignedBigInteger('lang_id')->nullable();
            $table->string('timezone')->default('Asia/Kolkata');
            $table->string('status')->default('active');
            $table->unsignedBigInteger('subscription_plan_id')->nullable();
            $table->date('licence_expire_on')->nullable();
            $table->timestamp('trial_ends_at')->nullable();
            $table->string('package_type', 20)->default('monthly');
            $table->unsignedBigInteger('admin_id')->nullable();
            $table->integer('total_users')->default(1);
            $table->time('clock_in_time')->default('09:30:00');
            $table->time('clock_out_time')->default('18:00:00');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('companies');
    }
};
