Refactor script

This commit is contained in:
furen81
2026-02-07 04:52:11 +07:00
parent 6e681c4ad3
commit c1ef2df512
20 changed files with 1608 additions and 118 deletions

View File

@ -0,0 +1,45 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use App\Models\Agent;
class FixMasterAgentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$id = 'AGT-MASTER';
// Cek existing
$agent = Agent::where('agent_id', $id)->first();
$data = [
'agent_id' => $id,
'company_name' => 'Kartsandy', // Case insensitive lookup will handle 'kartsandy'
'employee_id' => 'gurubesar', // [NEW] User preference
// 'username' => 'gurunesar', // Deprecated preference
'email' => 'andy@gmail.com',
'phone' => '08123456789',
'address' => 'Jakarta Headquarters',
'subscription_duration' => 9999, // Forever
'is_active' => true,
'role' => 'master',
'ip_whitelist' => [],
'api_secret_key' => 'sk_live_' . $id, // sk_live_AGT-MASTER matches frontend default
'password' => Hash::make('abcd1234'),
];
if ($agent) {
$agent->update($data);
$this->command->info("Updated Agent: {$id}");
} else {
Agent::create($data);
$this->command->info("Created Agent: {$id}");
}
}
}