Snapshot of main at 9f39a6e1e (2026-11-02)

This commit is contained in:
Ronald Huynen committed 2026-11-02 10:41:47 +01:00
commit 6ccf1792d7
2580 files changed
+1040202

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
<?php
namespace App\Http\Livewire;
use App\Models\Account;
use App\Models\Transaction;
use Livewire\Component;
class AccountUsageBar extends Component
{
public $selectedAccount;
public $balancePct = 1;
public $hasTransactions = false;
public $profileLimitMax = 0;
public $profileAccountCount = 1;
protected $listeners = [
'fromAccountId',
];
public function mount()
{
$this->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');
}
}