From c7731bfd9b533ec71b85741eada2e4464785ca8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Tue, 19 Jul 2022 02:28:47 +0300 Subject: [PATCH] fixed accounts show page --- app/Http/Controllers/Banking/Accounts.php | 13 +++--- .../views/banking/accounts/show.blade.php | 40 ++++++------------- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/app/Http/Controllers/Banking/Accounts.php b/app/Http/Controllers/Banking/Accounts.php index 0c7f55bbe..f3529fd4f 100644 --- a/app/Http/Controllers/Banking/Accounts.php +++ b/app/Http/Controllers/Banking/Accounts.php @@ -10,9 +10,9 @@ use App\Jobs\Banking\UpdateAccount; use App\Models\Banking\Account; use App\Models\Banking\Transaction; use App\Models\Banking\Transfer; -use App\Utilities\Reports as Utility; +use App\Utilities\Date; +use App\Utilities\Reports; use App\Models\Setting\Currency; -use Date; class Accounts extends Controller { @@ -35,11 +35,10 @@ class Accounts extends Controller */ public function show(Account $account) { - // Handle transactions - $transactions = Transaction::with('account', 'category')->where('account_id', $account->id)->collect('paid_at'); + $transactions = Transaction::with('category', 'contact', 'document')->where('account_id', $account->id)->collect(['paid_at'=> 'desc']); - $transfers = Transfer::with('expense_transaction', 'income_transaction')->get()->filter(function ($transfer) use($account) { - if ($transfer->expense_account->id == $account->id || $transfer->income_account->id == $account->id) { + $transfers = Transfer::with('expense_transaction', 'expense_transaction.account', 'income_transaction', 'income_transaction.account')->get()->filter(function ($transfer) use($account) { + if (($transfer->expense_transaction->account->id == $account->id) || ($transfer->income_transaction->account->id == $account->id)) { return true; } @@ -248,7 +247,7 @@ class Accounts extends Controller 'account_id' => $account->id, ]; - $report = Utility::getClassInstance('App\Reports\IncomeExpenseSummary'); + $report = Reports::getClassInstance('App\Reports\IncomeExpenseSummary'); if (empty($report) || empty($report->model)) { $message = trans('accounts.create_report'); diff --git a/resources/views/banking/accounts/show.blade.php b/resources/views/banking/accounts/show.blade.php index 060163ee0..10418dc77 100644 --- a/resources/views/banking/accounts/show.blade.php +++ b/resources/views/banking/accounts/show.blade.php @@ -225,7 +225,7 @@ - + @@ -243,11 +243,7 @@ - - - - - @@ -265,7 +261,7 @@ @foreach($transactions as $item) - + @@ -283,11 +279,7 @@ - - {{ $item->account->name }} - - -