<?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
    {
        Schema::create('employees', function (Blueprint $table) { $table->id(); $table->string('employee_code', 20)->unique(); $table->string('full_name'); $table->string('email')->unique(); $table->string('phone', 30)->nullable(); $table->string('position'); $table->string('department'); $table->date('join_date'); $table->enum('status', ['active','inactive'])->default('active'); $table->timestamps(); });
        Schema::create('attendances', function (Blueprint $table) { $table->id(); $table->foreignId('employee_id')->constrained()->cascadeOnDelete(); $table->date('attendance_date'); $table->dateTime('check_in')->nullable(); $table->dateTime('check_out')->nullable(); $table->string('photo_path')->nullable(); $table->decimal('latitude', 10, 7)->nullable(); $table->decimal('longitude', 10, 7)->nullable(); $table->string('location_name')->nullable(); $table->enum('status', ['present','late','absent','leave'])->default('present'); $table->string('notes')->nullable(); $table->timestamps(); $table->unique(['employee_id','attendance_date']); });
        Schema::create('leave_requests', function (Blueprint $table) { $table->id(); $table->foreignId('employee_id')->constrained()->cascadeOnDelete(); $table->enum('type', ['annual','sick','permission','other']); $table->date('start_date'); $table->date('end_date'); $table->text('reason'); $table->string('attachment')->nullable(); $table->enum('status', ['pending','approved','rejected'])->default('pending'); $table->string('review_note')->nullable(); $table->timestamps(); });
    }
    public function down(): void { Schema::dropIfExists('leave_requests'); Schema::dropIfExists('attendances'); Schema::dropIfExists('employees'); }
};
