feat: initial commit Sistem RKM Laravel (HSE, QMA, Pos Gerbang, QR Activity)

This commit is contained in:
Wahyudin
2026-10-12 23:47:41 +07:00
commit 21ce908199
94 changed files with 17600 additions and 0 deletions
@@ -0,0 +1,49 @@
<?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('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -0,0 +1,35 @@
<?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('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,57 @@
<?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('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,30 @@
<?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('gates', function (Blueprint $table) {
$table->id();
$table->string('code', 50)->unique();
$table->string('name', 100);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('gates');
}
};
@@ -0,0 +1,31 @@
<?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::table('users', function (Blueprint $table) {
$table->string('username', 50)->nullable()->unique()->after('name');
$table->string('role', 30)->default('gate_officer')->after('email');
$table->foreignId('gate_id')->nullable()->constrained('gates')->nullOnDelete()->after('role');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['gate_id']);
$table->dropColumn(['username', 'role', 'gate_id']);
});
}
};
@@ -0,0 +1,35 @@
<?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('nik', 50)->unique();
$table->string('name', 100);
$table->string('unit_kerja', 100)->nullable(); // Pembangkit, Bendungan, Teknik, Umum
$table->string('division', 100)->nullable();
$table->string('position', 100)->nullable();
$table->boolean('is_operator')->default(false);
$table->date('simper_expired_at')->nullable();
$table->string('photo_path')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('employees');
}
};
@@ -0,0 +1,50 @@
<?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('vehicles', function (Blueprint $table) {
$table->id();
$table->string('code', 50)->unique(); // LVCode / UnitCode
$table->string('category', 30)->default('light_vehicle'); // 'light_vehicle', 'unit_support'
$table->string('brand_type', 150); // MITSUBISHI - L300 - PICK UP
$table->string('license_plate', 30)->nullable(); // Nopol
$table->string('ownership', 150)->nullable(); // Teks bebas pemilik aset
$table->string('division', 100)->nullable();
$table->string('status', 50)->default('Operation'); // Operation, Standby, Breakdown
$table->decimal('current_km', 12, 2)->default(0); // Odometer KM terstandarisasi
$table->string('photo_path')->nullable();
// Atribut spesifik Kendaraan Berat (Unit Support) - nullable
$table->string('unit_category', 100)->nullable(); // Excavator, Crane, dll
$table->string('unit_type', 100)->nullable();
$table->string('brand', 100)->nullable();
$table->string('model_number', 100)->nullable();
$table->smallInteger('production_year')->nullable();
$table->string('location', 150)->nullable();
$table->decimal('fuel_consumption', 8, 2)->nullable();
$table->string('silo_document', 150)->nullable();
$table->string('stnk_document', 150)->nullable();
$table->string('pajak_document', 150)->nullable();
$table->string('kir_document', 150)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('vehicles');
}
};
@@ -0,0 +1,29 @@
<?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('security_guards', function (Blueprint $table) {
$table->id();
$table->string('name', 100);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('security_guards');
}
};
@@ -0,0 +1,45 @@
<?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('vehicle_activities', function (Blueprint $table) {
$table->id();
$table->string('transaction_no', 60)->unique();
$table->foreignId('vehicle_id')->constrained('vehicles')->cascadeOnDelete();
$table->foreignId('driver_id')->constrained('employees')->cascadeOnDelete();
$table->foreignId('gate_id')->constrained('gates')->cascadeOnDelete();
$table->string('direction', 10); // 'in', 'out'
$table->decimal('previous_km', 12, 2);
$table->decimal('current_km', 12, 2);
$table->decimal('distance', 12, 2); // current_km - previous_km
$table->text('purpose');
$table->timestamp('recorded_at');
$table->foreignId('security_guard_id')->nullable()->constrained('security_guards')->nullOnDelete();
$table->string('validation_status', 20)->default('pending'); // 'pending', 'approved', 'rejected'
$table->text('rejection_note')->nullable();
$table->timestamp('validated_at')->nullable();
$table->timestamps();
// Indexes untuk percepatan performa filter log & antrean gerbang
$table->index(['gate_id', 'validation_status']);
$table->index(['vehicle_id', 'recorded_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('vehicle_activities');
}
};