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
+1
View File
@@ -0,0 +1 @@
*.sqlite*
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends Factory<User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -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');
}
};
+253
View File
@@ -0,0 +1,253 @@
<?php
namespace Database\Seeders;
use App\Models\Employee;
use App\Models\Gate;
use App\Models\SecurityGuard;
use App\Models\User;
use App\Models\Vehicle;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
// 1. Seed Master Gates (Pos Gerbang Proyek PLTA Merangin)
$gateList = [
['code' => 'ADIT1', 'name' => 'Adit 1'],
['code' => 'ADIT2', 'name' => 'Adit 2'],
['code' => 'ADIT3', 'name' => 'Adit 3'],
['code' => 'BDG6', 'name' => 'Bedeng 6'],
['code' => 'BTUNGGAL', 'name' => 'Beringin Tunggal'],
['code' => 'CCRDAM', 'name' => 'CCR DAM'],
['code' => 'CRESTDAM', 'name' => 'Crest DAM'],
['code' => 'JAKON', 'name' => 'Dermaga Jakon'],
['code' => 'GUDANG', 'name' => 'Gudang Induk'],
['code' => 'KUMUN', 'name' => 'Mess Kumun'],
['code' => 'PHOFFICE', 'name' => 'PH - Office'],
['code' => 'PHUTAMA', 'name' => 'PH - Utama'],
['code' => 'REGWEIR', 'name' => 'Regulating Weir'],
['code' => 'VSHAFT', 'name' => 'Vertical Shaft'],
['code' => 'VSTPST', 'name' => 'VS - TPST'],
];
$createdGates = [];
foreach ($gateList as $g) {
$createdGates[$g['code']] = Gate::create([
'code' => $g['code'],
'name' => $g['name'],
'is_active' => true,
]);
}
// 2. Seed Master Security Guards (Satpam PG)
$guards = [
['name' => 'Ahmad Fauzi', 'is_active' => true],
['name' => 'Budi Santoso', 'is_active' => true],
['name' => 'Hendra Pratama', 'is_active' => true],
['name' => 'Rusli Efendi', 'is_active' => true],
['name' => 'Slamet Widodo', 'is_active' => true],
];
foreach ($guards as $guard) {
SecurityGuard::create($guard);
}
// 3. Seed Users (Admin & Shared Gate Accounts)
// Admin HSE [Nama : Mima, Username : 1185, Password : password]
User::create([
'name' => 'Mima',
'username' => '1185',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'hse_admin',
]);
// Admin QMA [Nama : Pinto Yuliandra, Username : 1171, Password : password]
User::create([
'name' => 'Pinto Yuliandra',
'username' => '1171',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'qma_admin',
]);
// Admin PG [Nama : Admin PG, Username : AdminPG, Password : password]
User::create([
'name' => 'Admin PG',
'username' => 'AdminPG',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'pg_admin',
]);
// Shared Gate Accounts (Akun Pos Gerbang)
User::create([
'name' => 'Pos Gerbang Beringin Tunggal',
'username' => 'pos.beringin',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'gate_officer',
'gate_id' => $createdGates['BTUNGGAL']->id,
]);
User::create([
'name' => 'Pos Gerbang Adit 1',
'username' => 'pos.adit1',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'gate_officer',
'gate_id' => $createdGates['ADIT1']->id,
]);
User::create([
'name' => 'Pos Gerbang Regulating Weir',
'username' => 'pos.regweir',
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'gate_officer',
'gate_id' => $createdGates['REGWEIR']->id,
]);
// 4. Seed Employees (Master Data HSE: Driver dengan SIMPER Valid dan Expired)
Employee::create([
'nik' => 'KMH-2022-001',
'name' => 'Eka Sufiatna',
'unit_kerja' => 'Teknik',
'division' => 'INFORMATION & TECHNOLOGY',
'position' => 'IT Division Coordinator',
'is_operator' => true,
'simper_expired_at' => Carbon::now()->addMonths(8), // SIMPER AKTIF
]);
Employee::create([
'nik' => 'KMH-2022-045',
'name' => 'Wanturi',
'unit_kerja' => 'Umum',
'division' => 'GA',
'position' => 'Driver Operasional',
'is_operator' => true,
'simper_expired_at' => Carbon::now()->addMonths(4), // SIMPER AKTIF
]);
Employee::create([
'nik' => 'KMH-2023-012',
'name' => 'Randi Kurniawan',
'unit_kerja' => 'Pembangkit',
'division' => 'Mechanical',
'position' => 'Operator Lapangan',
'is_operator' => true,
'simper_expired_at' => Carbon::now()->subDays(14), // SIMPER KEDALUWARSA (Untuk Test Validasi)
]);
Employee::create([
'nik' => 'KMH-2021-088',
'name' => 'Siti Rahma',
'unit_kerja' => 'Umum',
'division' => 'Keuangan',
'position' => 'Staff Finance',
'is_operator' => false, // BUKAN DRIVER
'simper_expired_at' => null,
]);
// 5. Seed Vehicles (Master Data QMA: Kendaraan Ringan / LV)
Vehicle::create([
'code' => 'LV62',
'category' => 'light_vehicle',
'brand_type' => 'MITSUBISHI - L300 - PICK UP',
'license_plate' => 'BH 8893 DI',
'ownership' => 'EKA SUFIATNA',
'division' => 'IT',
'status' => 'Operation',
'current_km' => 12500.00,
]);
Vehicle::create([
'code' => 'LV01',
'category' => 'light_vehicle',
'brand_type' => 'TOYOTA HILUX 4X4 DC',
'license_plate' => 'BH 1024 AB',
'ownership' => 'PT Kerinci Merangin Hidro',
'division' => 'HSE',
'status' => 'Operation',
'current_km' => 45200.00,
]);
Vehicle::create([
'code' => 'LV15',
'category' => 'light_vehicle',
'brand_type' => 'ISUZU D-MAX 4X4',
'license_plate' => 'BH 9012 CD',
'ownership' => 'Divisi Bendungan',
'division' => 'Bendungan',
'status' => 'Standby',
'current_km' => 28350.00,
]);
// 6. Seed Vehicles (Master Data QMA: Kendaraan Berat / Unit Support - HANYA Pencatatan Data)
Vehicle::create([
'code' => 'EX01',
'category' => 'unit_support',
'brand_type' => 'KOMATSU PC200-8',
'unit_category' => 'Excavator',
'unit_type' => 'Hydraulic Excavator',
'brand' => 'Komatsu',
'model_number' => 'PC200-8M0',
'production_year' => 2021,
'ownership' => 'PT KMH - Project',
'division' => 'Civil & Inviro',
'location' => 'Beringin Tunggal / Tunnel #2',
'status' => 'Operation',
'current_km' => 3450.00,
'fuel_consumption' => 18.50,
'silo_document' => 'SILO-KMH-2024/091',
'stnk_document' => 'STNK-BH-EX01',
'pajak_document' => 'PAJAK-2026/12',
'kir_document' => 'KIR-2026/08',
]);
Vehicle::create([
'code' => 'CR01',
'category' => 'unit_support',
'brand_type' => 'KATO SR-250R',
'unit_category' => 'Mobile Crane',
'unit_type' => 'Rough Terrain Crane 25T',
'brand' => 'Kato',
'model_number' => 'SR-250R',
'production_year' => 2019,
'ownership' => 'PT Kerinci Merangin Hidro',
'division' => 'Mechanical',
'location' => 'CCR DAM / Spillway',
'status' => 'Operation',
'current_km' => 1820.00,
'fuel_consumption' => 14.20,
'silo_document' => 'SILO-KMH-2025/112',
'kir_document' => 'KIR-2026/10',
]);
Vehicle::create([
'code' => 'DT02',
'category' => 'unit_support',
'brand_type' => 'MITSUBISHI FUSO FIGHTER FN62F',
'license_plate' => 'BH 8412 AA',
'unit_category' => 'Dump Truck',
'unit_type' => 'Dump Truck 20 Ton',
'brand' => 'Mitsubishi Fuso',
'model_number' => 'FN62F HD',
'production_year' => 2022,
'ownership' => 'PT KMH - Project',
'division' => 'Civil & Inviro',
'location' => 'Quarry & Disposal Area',
'status' => 'Standby',
'current_km' => 14800.00,
'fuel_consumption' => 28.00,
'stnk_document' => 'STNK-BH-8412-AA',
'kir_document' => 'KIR-2026/11',
]);
}
}