selectedAccount = [ 'id' => null, 'name' => '', 'balance' => 0, 'limitMin' => 0, 'limitMax' => 0, 'available' => 0, 'limitReceivable' => 0, ]; } public function fromAccountId($selectedAccount) { $this->selectedAccount = $selectedAccount; // Calculate balance percentage (set to 100% if limitMax is 0) $this->balancePct = $selectedAccount['limitMax'] == 0 ? 100 : ($selectedAccount['balance'] / $selectedAccount['limitMax']) * 100; $this->selectedAccount['available'] = $selectedAccount['limitMax'] - $selectedAccount['balance']; $this->hasTransactions = Transaction::where('from_account_id', $selectedAccount['id']) ->orWhere('to_account_id', $selectedAccount['id']) ->exists(); $account = Account::with('accountable')->find($selectedAccount['id']); $this->profileLimitMax = $account?->accountable?->limit_max ?? 0; $this->profileAccountCount = $account?->accountable?->accounts()->whereNull('inactive_at')->count() ?? 1; } public function render() { return view('livewire.account-usage-bar'); } }