<?php

declare(strict_types=1);

namespace Database\Seeders;

use App\Models\PartnerBalance;
use App\Models\User;
use Illuminate\Database\Seeder;

final class PartnerBalanceSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Get all users with partner role
        $partners = User::role('partner')->get();

        foreach ($partners as $partner) {
            $balance = PartnerBalance::firstOrCreate(
                ['partner_id' => $partner->id],
                [
                    'available_balance' => rand(5000, 50000),
                    'invested_balance' => rand(10000, 100000),
                    'total_balance' => 0,
                ]
            );

            // Update total balance
            $balance->updateBalances();
        }
    }
}
