<?php
require __DIR__ . '/core/vendor/autoload.php';
$app = require_once __DIR__ . '/core/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;

$password = Hash::make('password123');

for ($i = 1; $i <= 5; $i++) {
    $username = "user$i";
    $email = "user$i@example.com";
    $balance = rand(1000, 5000);
    
    $exists = DB::table('users')->where('username', $username)->first();
    if (!$exists) {
        DB::table('users')->insert([
            'firstname' => 'Test',
            'lastname' => "User$i",
            'username' => $username,
            'email' => $email,
            'password' => $password,
            'balance' => $balance,
            'status' => 1,
            'ev' => 1,
            'sv' => 1,
            'created_at' => now(),
            'updated_at' => now(),
        ]);
        echo "User $username created with balance $balance.\n";
    } else {
        DB::table('users')->where('id', $exists->id)->update(['balance' => $balance]);
        echo "User $username already exists. Updated balance to $balance.\n";
    }
}

echo "\nTotal 5 test users are ready with balance between 1000-5000.";
?>
