Akaunting/app/Widgets/AccountBalance.php

36 lines
840 B
PHP
Raw Normal View History

2019-11-16 07:21:14 +00:00
<?php
namespace App\Widgets;
2019-12-29 00:01:19 +00:00
use App\Abstracts\Widget;
2019-11-16 07:21:14 +00:00
use App\Models\Banking\Account;
2019-12-29 00:01:19 +00:00
class AccountBalance extends Widget
2019-11-16 07:21:14 +00:00
{
2020-01-15 21:42:20 +00:00
public $default_name = 'widgets.account_balance';
2020-01-10 14:49:31 +00:00
2022-06-01 07:15:55 +00:00
public $description = 'widgets.description.account_balance';
public $report_class = 'App\Reports\IncomeExpense';
2019-12-29 07:20:27 +00:00
public function show()
2026-02-07 18:55:11 +00:00
{
$this->setData();
return $this->view('widgets.account_balance', $this->data);
}
public function setData(): void
2019-11-16 07:21:14 +00:00
{
2023-05-31 11:40:05 +00:00
$accounts = Account::with('income_transactions', 'expense_transactions')->enabled()->take(5)->get()->map(function($account) {
$account->balance_formatted = money($account->balance, $account->currency_code);
2022-06-01 07:15:55 +00:00
return $account;
})->all();
2019-11-16 07:21:14 +00:00
2026-02-07 18:55:11 +00:00
$this->data = [
2019-11-16 07:21:14 +00:00
'accounts' => $accounts,
2026-02-07 18:55:11 +00:00
];
2019-11-16 07:21:14 +00:00
}
}