<?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('employees', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('phone')->nullable();
            $table->text('address')->nullable();
            $table->enum('gender', ['male', 'female', 'other'])->nullable();
            $table->string('email')->nullable();
            $table->enum('employee_type', ['employee', 'worker', 'shop_manager', 'shop_employee']);
            $table->enum('wage_type', ['salary', 'daily_wager', 'contract']);
            $table->decimal('basic_salary', 15, 2)->nullable();
            $table->decimal('daily_wage', 15, 2)->nullable();
            $table->decimal('contract_amount', 15, 2)->nullable();
            $table->integer('working_hours')->nullable();
            $table->integer('holidays_per_week')->nullable();
            $table->boolean('allow_login')->default(false);
            $table->string('username')->nullable();
            $table->string('password')->nullable();
            $table->unsignedBigInteger('shop_id')->nullable();
            $table->boolean('is_active')->default(true);
            $table->timestamps();

            $table->foreign('shop_id')->references('id')->on('shops')->onDelete('set null');
            $table->unique('username');
            $table->unique('email');
        });
    }

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