fix(hse): auto sync security guard personnel into employee simper master upon seeding and importing

This commit is contained in:
Ray1111-aa
2026-11-02 15:25:11 +07:00
parent 008e5f6b9d
commit 2fe265da37
2 changed files with 30 additions and 0 deletions
@@ -2,6 +2,7 @@
namespace App\Console\Commands;
use App\Models\Employee;
use App\Models\Gate;
use App\Models\SecurityGuard;
use App\Models\User;
@@ -105,6 +106,20 @@ class ImportSecurityGuardsCommand extends Command
$updatedGuards++;
}
// 3. Sinkronisasi Profil Master Personil / Karyawan (Data SIMPER)
Employee::updateOrCreate(
['nik' => $username],
[
'user_id' => $user->id,
'name' => $p['name'],
'employee_type' => 'Karyawan',
'unit_kerja' => 'Private Guard',
'division' => 'Private Guard',
'position' => 'Anggota',
'is_operator' => false,
]
);
$bar->advance();
}
+15
View File
@@ -2,6 +2,7 @@
namespace Database\Seeders;
use App\Models\Employee;
use App\Models\Gate;
use App\Models\SecurityGuard;
use App\Models\User;
@@ -86,6 +87,20 @@ class SecurityGuardSeeder extends Seeder
} else {
$updatedGuards++;
}
// 3. Sinkronisasi Profil Master Personil / Karyawan (Data SIMPER)
Employee::updateOrCreate(
['nik' => $username],
[
'user_id' => $user->id,
'name' => $p['name'],
'employee_type' => 'Karyawan',
'unit_kerja' => 'Private Guard',
'division' => 'Private Guard',
'position' => 'Anggota',
'is_operator' => false,
]
);
}
$this->command?->info("Selesai! {$insertedGuards} satpam baru, {$updatedGuards} satpam diperbarui, {$usersCreated} akun login user dibuat (password default: 123456).");