feat: complete master satpam with ID, Regu 1/2/3, Penempatan, and auto-generated guard login accounts
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?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('security_guards', function (Blueprint $table) {
|
||||
$table->string('badge_id', 50)->nullable()->unique()->after('id');
|
||||
$table->unsignedTinyInteger('team')->default(1)->after('name'); // Regu 1, 2, 3
|
||||
$table->foreignId('gate_id')->nullable()->constrained('gates')->nullOnDelete()->after('team');
|
||||
$table->foreignId('user_id')->nullable()->constrained('users')->nullOnDelete()->after('gate_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('security_guards', function (Blueprint $table) {
|
||||
$table->dropForeign(['gate_id']);
|
||||
$table->dropForeign(['user_id']);
|
||||
$table->dropColumn(['badge_id', 'team', 'gate_id', 'user_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -46,16 +46,34 @@ class DatabaseSeeder extends Seeder
|
||||
]);
|
||||
}
|
||||
|
||||
// 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],
|
||||
// 2. Seed Master Security Guards (Satpam PG Lengkap dengan Akun Login)
|
||||
$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 ($guards as $guard) {
|
||||
SecurityGuard::create($guard);
|
||||
|
||||
foreach ($guardData as $g) {
|
||||
$gateModel = $createdGates[$g['gate']];
|
||||
$guardUser = User::create([
|
||||
'name' => $g['name'],
|
||||
'username' => $g['badge_id'],
|
||||
'email' => strtolower($g['badge_id']) . '@kmh.co.id',
|
||||
'password' => Hash::make('password'),
|
||||
'role' => 'gate_officer',
|
||||
'gate_id' => $gateModel->id,
|
||||
]);
|
||||
|
||||
SecurityGuard::create([
|
||||
'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 (Admin & Shared Gate Accounts)
|
||||
|
||||
Reference in New Issue
Block a user