refactor: decouple credentials to env, modularize seeders, clean dead views, and track vite build
This commit is contained in:
@@ -59,3 +59,15 @@ MAIL_USERNAME=null
|
|||||||
MAIL_PASSWORD=null
|
MAIL_PASSWORD=null
|
||||||
MAIL_FROM_ADDRESS="[email protected]"
|
MAIL_FROM_ADDRESS="[email protected]"
|
||||||
MAIL_FROM_NAME="${APP_NAME}"
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# INITIAL SYSTEM CREDENTIALS & SEEDER
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
SUPERADMIN_NAME="Super Administrator"
|
||||||
|
SUPERADMIN_USERNAME=superadmin
|
||||||
|
SUPERADMIN_EMAIL=[email protected]
|
||||||
|
SUPERADMIN_PASSWORD=password
|
||||||
|
DEFAULT_EMPLOYEE_PASSWORD=123456
|
||||||
|
DEFAULT_USER_PASSWORD=password
|
||||||
|
SEED_SAMPLE_DATA=false
|
||||||
|
|
||||||
|
|||||||
@@ -64,3 +64,15 @@ AWS_BUCKET=
|
|||||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
VITE_APP_NAME="${APP_NAME}"
|
VITE_APP_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# INITIAL SYSTEM CREDENTIALS & SEEDER
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
SUPERADMIN_NAME="Super Administrator"
|
||||||
|
SUPERADMIN_USERNAME=superadmin
|
||||||
|
SUPERADMIN_EMAIL=[email protected]
|
||||||
|
SUPERADMIN_PASSWORD=password
|
||||||
|
DEFAULT_EMPLOYEE_PASSWORD=123456
|
||||||
|
DEFAULT_USER_PASSWORD=password
|
||||||
|
SEED_SAMPLE_DATA=false
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
/.zed
|
/.zed
|
||||||
/auth.json
|
/auth.json
|
||||||
/node_modules
|
/node_modules
|
||||||
/public/build
|
|
||||||
/public/hot
|
/public/hot
|
||||||
/public/storage
|
/public/storage
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ class EmployeeController extends Controller
|
|||||||
[
|
[
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'email' => $cleanEmail,
|
'email' => $cleanEmail,
|
||||||
'password' => Hash::make('123456'),
|
'password' => Hash::make(config('auth.default_employee_password', '123456')),
|
||||||
'role' => 'employee',
|
'role' => 'employee',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -556,7 +556,7 @@ class EmployeeController extends Controller
|
|||||||
[
|
[
|
||||||
'name' => $validated['name'],
|
'name' => $validated['name'],
|
||||||
'email' => strtolower(str_replace(['-', ' '], '', $validated['nik'])) . '@kmh.co.id',
|
'email' => strtolower(str_replace(['-', ' '], '', $validated['nik'])) . '@kmh.co.id',
|
||||||
'password' => Hash::make('123456'),
|
'password' => Hash::make(config('auth.default_employee_password', '123456')),
|
||||||
'role' => 'employee',
|
'role' => 'employee',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -114,4 +114,18 @@ return [
|
|||||||
|
|
||||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default System Credentials (Configurable via Environment Variables)
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'superadmin' => [
|
||||||
|
'name' => env('SUPERADMIN_NAME', 'Super Administrator'),
|
||||||
|
'username' => env('SUPERADMIN_USERNAME', 'superadmin'),
|
||||||
|
'email' => env('SUPERADMIN_EMAIL', '[email protected]'),
|
||||||
|
'password' => env('SUPERADMIN_PASSWORD', 'password'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'default_employee_password' => env('DEFAULT_EMPLOYEE_PASSWORD', '123456'),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -2,23 +2,18 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use App\Models\Employee;
|
|
||||||
use App\Models\Gate;
|
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\Database\Seeder;
|
||||||
use Illuminate\Support\Facades\Hash;
|
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Seed the application's database.
|
* Seed the application's database.
|
||||||
|
* Mengisi data master esensial sistem (Pos Gerbang, RBAC, Super Admin, dan Template P2H).
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
// 1. Seed Master Gates (Pos Gerbang Proyek PLTA Merangin)
|
// 1. Seed Master Gates (15 Pos Gerbang Proyek PLTA Merangin 350 MW)
|
||||||
$gateList = [
|
$gateList = [
|
||||||
['code' => 'ADIT1', 'name' => 'Adit 1'],
|
['code' => 'ADIT1', 'name' => 'Adit 1'],
|
||||||
['code' => 'ADIT2', 'name' => 'Adit 2'],
|
['code' => 'ADIT2', 'name' => 'Adit 2'],
|
||||||
@@ -37,9 +32,8 @@ class DatabaseSeeder extends Seeder
|
|||||||
['code' => 'VSTPST', 'name' => 'VS - TPST'],
|
['code' => 'VSTPST', 'name' => 'VS - TPST'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$createdGates = [];
|
|
||||||
foreach ($gateList as $g) {
|
foreach ($gateList as $g) {
|
||||||
$createdGates[$g['code']] = Gate::firstOrCreate([
|
Gate::firstOrCreate([
|
||||||
'code' => $g['code'],
|
'code' => $g['code'],
|
||||||
], [
|
], [
|
||||||
'name' => $g['name'],
|
'name' => $g['name'],
|
||||||
@@ -47,238 +41,17 @@ class DatabaseSeeder extends Seeder
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Seed Master Security Guards (Satpam PG Lengkap dengan Akun Login)
|
// 2. Seed RBAC Roles, Permissions & Akun Super Admin Utama (Kredensial dari .env)
|
||||||
$guardData = [
|
|
||||||
['badge_id' => 'SEC-001', 'name' => 'Ahmad Fauzi', 'team' => 1, 'gate' => 'BTUNGGAL'],
|
|
||||||
['badge_id' => 'SEC-002', 'name' => 'Budi Santoso', 'team' => 2, 'gate' => 'ADIT1'],
|
|
||||||
['badge_id' => 'SEC-003', 'name' => 'Hendra Pratama', 'team' => 3, 'gate' => 'REGWEIR'],
|
|
||||||
['badge_id' => 'SEC-004', 'name' => 'Rusli Efendi', 'team' => 1, 'gate' => 'ADIT2'],
|
|
||||||
['badge_id' => 'SEC-005', 'name' => 'Slamet Widodo', 'team' => 2, 'gate' => 'ADIT3'],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($guardData as $g) {
|
|
||||||
$gateModel = $createdGates[$g['gate']];
|
|
||||||
$guardUser = User::firstOrCreate([
|
|
||||||
'username' => $g['badge_id'],
|
|
||||||
], [
|
|
||||||
'name' => $g['name'],
|
|
||||||
'email' => strtolower($g['badge_id']) . '@kmh.co.id',
|
|
||||||
'password' => Hash::make('password'),
|
|
||||||
'role' => 'gate_officer',
|
|
||||||
'gate_id' => $gateModel->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
SecurityGuard::firstOrCreate([
|
|
||||||
'badge_id' => $g['badge_id'],
|
|
||||||
], [
|
|
||||||
'name' => $g['name'],
|
|
||||||
'team' => $g['team'],
|
|
||||||
'gate_id' => $gateModel->id,
|
|
||||||
'user_id' => $guardUser->id,
|
|
||||||
'is_active' => true,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Seed Users (Super Admin, Dept Admins & Shared Gate Accounts)
|
|
||||||
// Super Admin [Nama : Super Administrator, Username : superadmin, Password : password]
|
|
||||||
User::firstOrCreate([
|
|
||||||
'username' => 'superadmin',
|
|
||||||
], [
|
|
||||||
'name' => 'Super Administrator',
|
|
||||||
'email' => '[email protected]',
|
|
||||||
'password' => Hash::make('password'),
|
|
||||||
'role' => 'super_admin',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Admin HSE [Nama : Mima, Username : 1185, Password : password]
|
|
||||||
User::firstOrCreate([
|
|
||||||
'username' => '1185',
|
|
||||||
], [
|
|
||||||
'name' => 'Mima',
|
|
||||||
'email' => '[email protected]',
|
|
||||||
'password' => Hash::make('password'),
|
|
||||||
'role' => 'hse_admin',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Admin QMA [Nama : Pinto Yuliandra, Username : 1171, Password : password]
|
|
||||||
User::firstOrCreate([
|
|
||||||
'username' => '1171',
|
|
||||||
], [
|
|
||||||
'name' => 'Pinto Yuliandra',
|
|
||||||
'email' => '[email protected]',
|
|
||||||
'password' => Hash::make('password'),
|
|
||||||
'role' => 'qma_admin',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Admin PG [Nama : Admin PG, Username : AdminPG, Password : password]
|
|
||||||
User::firstOrCreate([
|
|
||||||
'username' => 'AdminPG',
|
|
||||||
], [
|
|
||||||
'name' => 'Admin PG',
|
|
||||||
'email' => '[email protected]',
|
|
||||||
'password' => Hash::make('password'),
|
|
||||||
'role' => 'pg_admin',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// 4. Seed Employees (Master Data HSE & Akun Login Karyawan dengan Role 'employee')
|
|
||||||
$employeesData = [
|
|
||||||
[
|
|
||||||
'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
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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)
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'nik' => 'KMH-2021-088',
|
|
||||||
'name' => 'Siti Rahma',
|
|
||||||
'unit_kerja' => 'Umum',
|
|
||||||
'division' => 'Keuangan',
|
|
||||||
'position' => 'Staff Finance',
|
|
||||||
'is_operator' => false, // BUKAN DRIVER
|
|
||||||
'simper_expired_at' => null,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($employeesData as $emp) {
|
|
||||||
$empUser = User::firstOrCreate([
|
|
||||||
'username' => $emp['nik'],
|
|
||||||
], [
|
|
||||||
'name' => $emp['name'],
|
|
||||||
'email' => strtolower(str_replace(['-', ' '], '', $emp['nik'])) . '@kmh.co.id',
|
|
||||||
'password' => Hash::make('password'),
|
|
||||||
'role' => 'employee',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$emp['user_id'] = $empUser->id;
|
|
||||||
Employee::firstOrCreate(['nik' => $emp['nik']], $emp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. Seed Vehicles (Master Data QMA: Kendaraan Ringan / LV)
|
|
||||||
Vehicle::firstOrCreate([
|
|
||||||
'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::firstOrCreate([
|
|
||||||
'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::firstOrCreate([
|
|
||||||
'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::firstOrCreate([
|
|
||||||
'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::firstOrCreate([
|
|
||||||
'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::firstOrCreate([
|
|
||||||
'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',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// 6. Seed RBAC Roles, Permissions & Super Admin
|
|
||||||
$this->call(RolePermissionSeeder::class);
|
$this->call(RolePermissionSeeder::class);
|
||||||
|
|
||||||
// 7. Seed 28 Master Template P2H Unit Support
|
// 3. Seed 28 Master Template Checksheet P2H Unit Support & Pertanyaan Pemeriksaan
|
||||||
$this->call(P2hTemplateSeeder::class);
|
$this->call(P2hTemplateSeeder::class);
|
||||||
|
|
||||||
|
// 4. Seed Data Uji Coba (Sample Satpam, Karyawan, Kendaraan LV & Alat Berat)
|
||||||
|
// Dijalankan di mode testing atau jika SEED_SAMPLE_DATA=true di .env
|
||||||
|
$seedSamples = app()->environment('testing') || filter_var(env('SEED_SAMPLE_DATA', false), FILTER_VALIDATE_BOOLEAN);
|
||||||
|
if ($seedSamples) {
|
||||||
|
$this->call(SampleTestingDataSeeder::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,13 +78,20 @@ class RolePermissionSeeder extends Seeder
|
|||||||
$role->syncPermissions($perms);
|
$role->syncPermissions($perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Buat Akun Default Super Admin
|
// 4. Buat Akun Default Super Admin (Mengambil dari config/auth.php & .env)
|
||||||
$superAdmin = User::firstOrCreate(
|
$superAdminConfig = config('auth.superadmin', [
|
||||||
['username' => 'superadmin'],
|
|
||||||
[
|
|
||||||
'name' => 'Super Administrator',
|
'name' => 'Super Administrator',
|
||||||
|
'username' => 'superadmin',
|
||||||
'email' => '[email protected]',
|
'email' => '[email protected]',
|
||||||
'password' => Hash::make('password'),
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$superAdmin = User::firstOrCreate(
|
||||||
|
['username' => $superAdminConfig['username']],
|
||||||
|
[
|
||||||
|
'name' => $superAdminConfig['name'],
|
||||||
|
'email' => $superAdminConfig['email'],
|
||||||
|
'password' => Hash::make($superAdminConfig['password']),
|
||||||
'role' => 'super_admin',
|
'role' => 'super_admin',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,262 @@
|
|||||||
|
<?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 SampleTestingDataSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Seed sample / mock data khusus untuk keperluan testing, staging, atau uji coba sistem.
|
||||||
|
* Tidak dijalankan di environment production kecuali SEED_SAMPLE_DATA=true.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$defaultPassword = config('auth.default_sample_password', env('DEFAULT_USER_PASSWORD', 'password'));
|
||||||
|
|
||||||
|
// 1. Ambil Pos Gerbang
|
||||||
|
$createdGates = Gate::all()->keyBy('code');
|
||||||
|
|
||||||
|
// 2. Seed Sample Satpam PG
|
||||||
|
$guardData = [
|
||||||
|
['badge_id' => 'SEC-001', 'name' => 'Ahmad Fauzi', 'team' => 1, 'gate' => 'BTUNGGAL'],
|
||||||
|
['badge_id' => 'SEC-002', 'name' => 'Budi Santoso', 'team' => 2, 'gate' => 'ADIT1'],
|
||||||
|
['badge_id' => 'SEC-003', 'name' => 'Hendra Pratama', 'team' => 3, 'gate' => 'REGWEIR'],
|
||||||
|
['badge_id' => 'SEC-004', 'name' => 'Rusli Efendi', 'team' => 1, 'gate' => 'ADIT2'],
|
||||||
|
['badge_id' => 'SEC-005', 'name' => 'Slamet Widodo', 'team' => 2, 'gate' => 'ADIT3'],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($guardData as $g) {
|
||||||
|
$gateModel = $createdGates[$g['gate']] ?? Gate::first();
|
||||||
|
$guardUser = User::firstOrCreate([
|
||||||
|
'username' => $g['badge_id'],
|
||||||
|
], [
|
||||||
|
'name' => $g['name'],
|
||||||
|
'email' => strtolower($g['badge_id']) . '@kmh.co.id',
|
||||||
|
'password' => Hash::make($defaultPassword),
|
||||||
|
'role' => 'gate_officer',
|
||||||
|
'gate_id' => $gateModel?->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!$guardUser->hasRole('gate_officer')) {
|
||||||
|
$guardUser->assignRole('gate_officer');
|
||||||
|
}
|
||||||
|
|
||||||
|
SecurityGuard::firstOrCreate([
|
||||||
|
'badge_id' => $g['badge_id'],
|
||||||
|
], [
|
||||||
|
'name' => $g['name'],
|
||||||
|
'team' => $g['team'],
|
||||||
|
'gate_id' => $gateModel?->id,
|
||||||
|
'user_id' => $guardUser->id,
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Seed Sample Department Admins
|
||||||
|
// Admin HSE [Nama : Mima, Username : 1185]
|
||||||
|
$hseUser = User::firstOrCreate([
|
||||||
|
'username' => '1185',
|
||||||
|
], [
|
||||||
|
'name' => 'Mima',
|
||||||
|
'email' => '[email protected]',
|
||||||
|
'password' => Hash::make($defaultPassword),
|
||||||
|
'role' => 'hse_admin',
|
||||||
|
]);
|
||||||
|
if (!$hseUser->hasRole('hse_admin')) {
|
||||||
|
$hseUser->assignRole('hse_admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Admin QMA [Nama : Pinto Yuliandra, Username : 1171]
|
||||||
|
$qmaUser = User::firstOrCreate([
|
||||||
|
'username' => '1171',
|
||||||
|
], [
|
||||||
|
'name' => 'Pinto Yuliandra',
|
||||||
|
'email' => '[email protected]',
|
||||||
|
'password' => Hash::make($defaultPassword),
|
||||||
|
'role' => 'qma_admin',
|
||||||
|
]);
|
||||||
|
if (!$qmaUser->hasRole('qma_admin')) {
|
||||||
|
$qmaUser->assignRole('qma_admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Admin PG [Nama : Admin PG, Username : AdminPG]
|
||||||
|
$pgUser = User::firstOrCreate([
|
||||||
|
'username' => 'AdminPG',
|
||||||
|
], [
|
||||||
|
'name' => 'Admin PG',
|
||||||
|
'email' => '[email protected]',
|
||||||
|
'password' => Hash::make($defaultPassword),
|
||||||
|
'role' => 'pg_admin',
|
||||||
|
]);
|
||||||
|
if (!$pgUser->hasRole('pg_admin')) {
|
||||||
|
$pgUser->assignRole('pg_admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Seed Sample Karyawan & Driver
|
||||||
|
$employeesData = [
|
||||||
|
[
|
||||||
|
'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),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nik' => 'KMH-2022-045',
|
||||||
|
'name' => 'Wanturi',
|
||||||
|
'unit_kerja' => 'Umum',
|
||||||
|
'division' => 'GA',
|
||||||
|
'position' => 'Driver Operasional',
|
||||||
|
'is_operator' => true,
|
||||||
|
'simper_expired_at' => Carbon::now()->addMonths(4),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'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),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'nik' => 'KMH-2021-088',
|
||||||
|
'name' => 'Siti Rahma',
|
||||||
|
'unit_kerja' => 'Umum',
|
||||||
|
'division' => 'Keuangan',
|
||||||
|
'position' => 'Staff Finance',
|
||||||
|
'is_operator' => false,
|
||||||
|
'simper_expired_at' => null,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($employeesData as $emp) {
|
||||||
|
$empUser = User::firstOrCreate([
|
||||||
|
'username' => $emp['nik'],
|
||||||
|
], [
|
||||||
|
'name' => $emp['name'],
|
||||||
|
'email' => strtolower(str_replace(['-', ' '], '', $emp['nik'])) . '@kmh.co.id',
|
||||||
|
'password' => Hash::make($defaultPassword),
|
||||||
|
'role' => 'employee',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!$empUser->hasRole('employee')) {
|
||||||
|
$empUser->assignRole('employee');
|
||||||
|
}
|
||||||
|
|
||||||
|
$emp['user_id'] = $empUser->id;
|
||||||
|
Employee::firstOrCreate(['nik' => $emp['nik']], $emp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. Seed Sample Light Vehicles
|
||||||
|
Vehicle::firstOrCreate([
|
||||||
|
'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::firstOrCreate([
|
||||||
|
'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::firstOrCreate([
|
||||||
|
'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 Sample Unit Support
|
||||||
|
Vehicle::firstOrCreate([
|
||||||
|
'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::firstOrCreate([
|
||||||
|
'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::firstOrCreate([
|
||||||
|
'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',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,14 +13,25 @@ class SuperAdminSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
User::updateOrCreate(
|
$superAdminConfig = config('auth.superadmin', [
|
||||||
['username' => 'superadmin'],
|
|
||||||
[
|
|
||||||
'name' => 'Super Administrator',
|
'name' => 'Super Administrator',
|
||||||
|
'username' => 'superadmin',
|
||||||
'email' => '[email protected]',
|
'email' => '[email protected]',
|
||||||
'password' => Hash::make('password'),
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$superAdmin = User::updateOrCreate(
|
||||||
|
['username' => $superAdminConfig['username']],
|
||||||
|
[
|
||||||
|
'name' => $superAdminConfig['name'],
|
||||||
|
'email' => $superAdminConfig['email'],
|
||||||
|
'password' => Hash::make($superAdminConfig['password']),
|
||||||
'role' => 'super_admin',
|
'role' => 'super_admin',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!$superAdmin->hasRole('super_admin')) {
|
||||||
|
$superAdmin->assignRole('super_admin');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"resources/css/app.css": {
|
||||||
|
"file": "assets/app-dNtE81P0.css",
|
||||||
|
"src": "resources/css/app.css",
|
||||||
|
"isEntry": true,
|
||||||
|
"name": "app",
|
||||||
|
"names": [
|
||||||
|
"app.css"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"resources/js/app.js": {
|
||||||
|
"file": "assets/app-DMsN-rLE.js",
|
||||||
|
"name": "app",
|
||||||
|
"src": "resources/js/app.js",
|
||||||
|
"isEntry": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -228,14 +228,14 @@
|
|||||||
<!-- Kode LV -->
|
<!-- Kode LV -->
|
||||||
<td class="py-3.5 px-4 text-center whitespace-nowrap font-mono">
|
<td class="py-3.5 px-4 text-center whitespace-nowrap font-mono">
|
||||||
<span class="inline-block bg-emerald-50 text-emerald-800 font-bold px-2.5 py-1 rounded border border-emerald-200">
|
<span class="inline-block bg-emerald-50 text-emerald-800 font-bold px-2.5 py-1 rounded border border-emerald-200">
|
||||||
{{ $act->vehicle->code }}
|
{{ $act->vehicle?->code ?? '-' }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- Unit & Plat -->
|
<!-- Unit & Plat -->
|
||||||
<td class="py-3.5 px-4 min-w-[220px]">
|
<td class="py-3.5 px-4 min-w-[220px]">
|
||||||
<div class="font-bold text-slate-900 whitespace-nowrap">{{ $act->vehicle->brand_type }}</div>
|
<div class="font-bold text-slate-900 whitespace-nowrap">{{ $act->vehicle?->brand_type ?? '-' }}</div>
|
||||||
@if($act->vehicle->license_plate)
|
@if($act->vehicle?->license_plate)
|
||||||
<span class="inline-block text-[10px] font-mono font-bold text-amber-800 bg-amber-50 px-2 py-0.5 rounded border border-amber-200 mt-0.5 whitespace-nowrap">
|
<span class="inline-block text-[10px] font-mono font-bold text-amber-800 bg-amber-50 px-2 py-0.5 rounded border border-amber-200 mt-0.5 whitespace-nowrap">
|
||||||
{{ $act->vehicle->license_plate }}
|
{{ $act->vehicle->license_plate }}
|
||||||
</span>
|
</span>
|
||||||
@@ -246,19 +246,19 @@
|
|||||||
|
|
||||||
<!-- Penanggung Jawab -->
|
<!-- Penanggung Jawab -->
|
||||||
<td class="py-3.5 px-4 text-slate-600 font-medium">
|
<td class="py-3.5 px-4 text-slate-600 font-medium">
|
||||||
{{ $act->vehicle->ownership ?? '-' }}
|
{{ $act->vehicle?->ownership ?? '-' }}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- Driver -->
|
<!-- Driver -->
|
||||||
<td class="py-3.5 px-4">
|
<td class="py-3.5 px-4">
|
||||||
<div class="font-bold text-slate-900">{{ $act->driver->name }}</div>
|
<div class="font-bold text-slate-900">{{ $act->driver?->name ?? '-' }}</div>
|
||||||
<div class="text-[10px] text-slate-400 font-normal">{{ $act->driver->division ?? '-' }}</div>
|
<div class="text-[10px] text-slate-400 font-normal">{{ $act->driver?->division ?? '-' }}</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- Gate -->
|
<!-- Gate -->
|
||||||
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
<span class="inline-flex items-center px-2.5 py-1 rounded-lg text-xs font-semibold bg-slate-100 text-slate-700 border border-slate-200">
|
<span class="inline-flex items-center px-2.5 py-1 rounded-lg text-xs font-semibold bg-slate-100 text-slate-700 border border-slate-200">
|
||||||
{{ $act->gate->name }}
|
{{ $act->gate?->name ?? '-' }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@@ -332,9 +332,9 @@
|
|||||||
onclick="openQmaOdometerModal({{ json_encode([
|
onclick="openQmaOdometerModal({{ json_encode([
|
||||||
'id' => $act->id,
|
'id' => $act->id,
|
||||||
'trx' => $act->transaction_no,
|
'trx' => $act->transaction_no,
|
||||||
'code' => $act->vehicle->code,
|
'code' => $act->vehicle?->code ?? '-',
|
||||||
'unit' => $act->vehicle->brand_type,
|
'unit' => $act->vehicle?->brand_type ?? 'Kendaraan',
|
||||||
'driver' => $act->driver->name,
|
'driver' => $act->driver?->name ?? 'Pengemudi',
|
||||||
'previous_km' => (float)$act->previous_km,
|
'previous_km' => (float)$act->previous_km,
|
||||||
'current_km' => (float)$act->current_km,
|
'current_km' => (float)$act->current_km,
|
||||||
'distance' => (float)$act->distance,
|
'distance' => (float)$act->distance,
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
@extends('layouts.app')
|
|
||||||
|
|
||||||
@section('title', 'Dashboard Admin - Super Admin | PT Kerinci Merangin Hidro')
|
|
||||||
|
|
||||||
@section('content')
|
|
||||||
<div class="w-full space-y-6">
|
|
||||||
|
|
||||||
<!-- Header Judul Halaman -->
|
|
||||||
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
|
||||||
<div>
|
|
||||||
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
|
|
||||||
Dashboard Admin
|
|
||||||
</h2>
|
|
||||||
<p class="text-xs sm:text-sm text-slate-500 mt-1">
|
|
||||||
Pusat ikhtisar operasional dan analitik sistem terintegrasi PT Kerinci Merangin Hidro.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Konten Dashboard Kosong (Placeholder Persiapan Awal) -->
|
|
||||||
<div class="bg-white rounded-2xl border border-slate-200/80 p-12 sm:p-16 text-center shadow-xs">
|
|
||||||
<div class="w-16 h-16 mx-auto rounded-2xl bg-slate-100 text-slate-400 flex items-center justify-center text-2xl mb-4">
|
|
||||||
<i class="fa-solid fa-chart-pie"></i>
|
|
||||||
</div>
|
|
||||||
<h3 class="text-base sm:text-lg font-bold text-slate-800">
|
|
||||||
Halaman Dashboard Sedang Disiapkan
|
|
||||||
</h3>
|
|
||||||
<p class="text-xs sm:text-sm text-slate-400 max-w-md mx-auto mt-1 mb-6">
|
|
||||||
Komponen analitik, grafik metrik aktivitas, dan rekapitulasi data sistem saat ini masih dalam tahap perancangan awal.
|
|
||||||
</p>
|
|
||||||
<a href="{{ route('superadmin.roles.index') }}"
|
|
||||||
class="inline-flex items-center space-x-2 px-4 py-2.5 rounded-xl bg-[#1b5e20] hover:bg-[#144919] text-white text-xs font-bold transition shadow-sm">
|
|
||||||
<i class="fa-solid fa-users-gear text-xs"></i>
|
|
||||||
<span>Buka Manajemen Role</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
@endsection
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user