46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?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}");
|
|
}
|
|
}
|
|
}
|