akaunting/app/Widgets/AccountBalance.php

29 lines
729 B
PHP
Raw Permalink Normal View History

2019-11-16 10:21:14 +03:00
<?php
namespace App\Widgets;
2019-12-29 03:01:19 +03:00
use App\Abstracts\Widget;
2019-11-16 10:21:14 +03:00
use App\Models\Banking\Account;
2019-12-29 03:01:19 +03:00
class AccountBalance extends Widget
2019-11-16 10:21:14 +03:00
{
2020-01-16 00:42:20 +03:00
public $default_name = 'widgets.account_balance';
2020-01-10 17:49:31 +03:00
2022-06-01 10:15:55 +03:00
public $description = 'widgets.description.account_balance';
public $report_class = 'App\Reports\IncomeExpense';
2019-12-29 10:20:27 +03:00
public function show()
2019-11-16 10:21:14 +03:00
{
2023-05-31 14:40:05 +03: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 10:15:55 +03:00
return $account;
})->all();
2019-11-16 10:21:14 +03:00
2019-12-31 02:20:10 +03:00
return $this->view('widgets.account_balance', [
2019-11-16 10:21:14 +03:00
'accounts' => $accounts,
]);
}
}