<?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('users')) {
            return;
        }
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_id')->nullable();
            $table->unsignedBigInteger('role_id')->nullable();
            $table->boolean('is_superadmin')->default(false);
            $table->string('user_type')->default('staff_members');
            $table->boolean('login_enabled')->default(true);
            $table->string('name');
            $table->string('employee_number')->nullable();
            $table->string('email', 191)->unique();
            $table->string('password')->nullable();
            $table->string('phone')->nullable();
            $table->string('gender', 20)->default('female');
            $table->date('dob')->nullable();
            $table->date('joining_date')->nullable();
            $table->boolean('allow_login')->default(true);
            $table->unsignedBigInteger('report_to')->nullable();
            $table->string('visibility', 20)->default('individual');
            $table->unsignedBigInteger('department_id')->nullable();
            $table->unsignedBigInteger('designation_id')->nullable();
            $table->unsignedBigInteger('shift_id')->nullable();
            $table->unsignedBigInteger('location_id')->nullable();
            $table->unsignedBigInteger('salary_group_id')->nullable();
            $table->string('status')->default('active');
            $table->string('timezone', 50)->default('Asia/Kolkata');
            $table->timestamp('email_verified_at')->nullable();
            $table->rememberToken();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('users');
    }
};
