
PK 
<?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('employee_loans', function (Blueprint $table) {
$table->id();
$table->foreignId('employee_id')
->constrained('employees')
->cascadeOnDelete();
$table->enum('type', ['Loan', 'Advance']);
$table->string('purpose', 255)->nullable();
$table->decimal('principal_amount', 15, 2);
$table->decimal('interest_rate', 5, 2)->default(0); // annual %
$table->integer('tenure_months')->nullable();
$table->decimal('emi_amount', 15, 2)->nullable();
$table->decimal('outstanding_amount', 15, 2);
$table->date('start_date');
$table->date('end_date')->nullable();
$table->enum('status', [
'Active',
'Completed',
'Closed'
])->default('Active');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('employee_loans');
}
};


PK 99