From 90190bb3018f3e9316d0807c3569c90c36a195d5 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 2 Jul 2021 15:10:22 +1000 Subject: [PATCH] Performance workarounds as a result of 1bba21 - need to work on with() --- app/Http/Controllers/HomeController.php | 4 +++- .../adminlte/common/account/widget/summary.blade.php | 7 ++++--- .../theme/backend/adminlte/u/invoice/widgets/due.blade.php | 4 ++-- .../backend/adminlte/u/invoice/widgets/list.blade.php | 4 ++-- .../backend/adminlte/u/payment/widgets/list.blade.php | 4 ++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 9f9d300..8ff4d5f 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -35,8 +35,10 @@ class HomeController extends Controller public function home(User $o): View { // If we are passed a user to view, we'll open up their home page. - if ($o->exists) + if ($o->exists) { + $o->load(['accounts','services']); return View('u.home',['o'=>$o]); + } // If User was null, then test and see what type of logged on user we have $o = Auth::user(); diff --git a/resources/views/theme/backend/adminlte/common/account/widget/summary.blade.php b/resources/views/theme/backend/adminlte/common/account/widget/summary.blade.php index 980619d..b0b8304 100644 --- a/resources/views/theme/backend/adminlte/common/account/widget/summary.blade.php +++ b/resources/views/theme/backend/adminlte/common/account/widget/summary.blade.php @@ -17,6 +17,7 @@
Active Services + {{ $o->services->count() }} /{{ $o->services->count() }}
@@ -28,7 +29,7 @@
Account Balance - $ {{ number_format($o->invoices_due->sum('due'),2) }} + $ {{ number_format(($x=$o->invoices()->with(['items.taxes','paymentitems.payment','account'])->get()->where('due','>',0))->sum('due'),2) }}
@@ -39,7 +40,7 @@
Invoices Due - {{ $o->invoices_due->count() }} + {{ $x->count() }}
- + \ No newline at end of file diff --git a/resources/views/theme/backend/adminlte/u/invoice/widgets/due.blade.php b/resources/views/theme/backend/adminlte/u/invoice/widgets/due.blade.php index da51d69..b09c725 100644 --- a/resources/views/theme/backend/adminlte/u/invoice/widgets/due.blade.php +++ b/resources/views/theme/backend/adminlte/u/invoice/widgets/due.blade.php @@ -5,7 +5,7 @@
- @if($o->invoices->where('due','>',0)->count()) + @if(($x=$o->invoices()->with(['items.taxes','paymentitems.payment','account'])->get()->where('due','>',0))->count()) @@ -20,7 +20,7 @@ - @foreach ($o->invoices->where('due','>',0) as $oo) + @foreach ($x as $oo) due_date->isPast()) class="table-danger" @endif> diff --git a/resources/views/theme/backend/adminlte/u/invoice/widgets/list.blade.php b/resources/views/theme/backend/adminlte/u/invoice/widgets/list.blade.php index c0f6ba9..d87dec5 100644 --- a/resources/views/theme/backend/adminlte/u/invoice/widgets/list.blade.php +++ b/resources/views/theme/backend/adminlte/u/invoice/widgets/list.blade.php @@ -5,7 +5,7 @@
- @if($o->invoices->where('date_orig','>',($x=\Carbon\Carbon::now()->subMonths(12)))->where('due','=',0)->count()) + @if(($x=$o->invoices()->where('ab_invoice.date_orig','>',\Carbon\Carbon::now()->subMonths(12)->unix())->with(['items.taxes','paymentitems.payment','account.country.currency'])->get()->where('due','<=',0))->count())
{{ $oo->account->name }} {{ $oo->sid }}
@@ -19,7 +19,7 @@ - @foreach ($o->invoices->where('date_orig','>',$x)->where('due','=',0) as $oo) + @foreach ($x as $oo) diff --git a/resources/views/theme/backend/adminlte/u/payment/widgets/list.blade.php b/resources/views/theme/backend/adminlte/u/payment/widgets/list.blade.php index 4fdbb3a..2fe0567 100644 --- a/resources/views/theme/backend/adminlte/u/payment/widgets/list.blade.php +++ b/resources/views/theme/backend/adminlte/u/payment/widgets/list.blade.php @@ -5,7 +5,7 @@
- @if($o->payments->where('date_orig','>',($x=\Carbon\Carbon::now()->subMonths(12)))->count()) + @if(($x=$o->payments()->where('ab_payment.date_orig','>',\Carbon\Carbon::now()->subMonths(12)->unix())->with(['items','account'])->get())->count())
{{ $oo->account->name }} {{ $oo->sid }}
@@ -19,7 +19,7 @@ - @foreach ($o->payments->where('date_orig','>',($x=\Carbon\Carbon::now()->subMonths(12))) as $oo) + @foreach ($x as $oo)
{{ $oo->account->name }} {{ $oo->sid }}