Home page performance optimisations

This commit is contained in:
Deon George 2024-07-09 21:09:34 +10:00
parent f561139d45
commit 28aa1f9dc8
2 changed files with 12 additions and 4 deletions

View File

@ -4,7 +4,7 @@
</div>
<div class="card-body">
@if ($x=$user->accounts_all->count())
@if($x=$o->accounts_all->count())
<table class="table table-striped table-hover" id="accounts">
<thead>
<tr>
@ -14,7 +14,10 @@
</tr>
</thead>
<tbody>
@foreach ($user->accounts_all as $ao)
@foreach($o->accounts_all as $ao)
@php
$ao->load(['services:id,active,account_id']);
@endphp
<tr>
<td><a href="{{ url('r/switch/start',$ao->user_id) }}"><i class="fas fa-external-link-alt"></i></a></td>
<td>{{ $ao->name }}</td>

View File

@ -1,3 +1,8 @@
@php
use App\Models\{Account,Service};
$acts = $o->accounts_all->pluck('id');
@endphp
@if($user->isReseller() && ($o->accounts->count() <= 2) && ($x=$o->accounts->pluck('providers')->flatten())->count())
<div class="col-12 col-sm-4 col-md-2">
<div class="info-box">
@ -31,7 +36,7 @@
<div class="info-box-content">
<span class="info-box-text">Active Services</span>
<span class="info-box-number">{{ $o->accounts_all->map(fn($item)=>$item->services->where('active',TRUE)->count())->sum() }} <small>/{{ $o->accounts_all->map(fn($item)=>$item->services->count())->sum() }}</small></span>
<span class="info-box-number">{{ Service::active()->whereIn('account_id',$acts)->count() }} <small>/{{ Service::whereIn('account_id',$acts)->count() }}</small></span>
</div>
</div>
</div>
@ -42,7 +47,7 @@
<div class="info-box-content">
<span class="info-box-text">Account Balance</span>
<span class="info-box-number"><small>$</small> {{ number_format(($x=$o->accounts_all->map(fn($item)=>$item->invoiceSummaryDue()->get()->pluck('_balance'))->flatten())->sum(),2) }}</span>
<span class="info-box-number"><small>$</small> {{ number_format(($x=Account::InvoicesDue()->filter(fn($item)=>$acts->contains($item->account_id)))->sum('_balance'),2) }}</span>
</div>
</div>
</div>