php - How to sum at once in loop without waiting? -


my view blade :

... @foreach($orders $order)     ...     <td>{{ $order->sumtotal['total'] }}</td>     ... @endforeach ... 

my model :

public function getsumtotalattribute() {     $total = order::where('year','=', '2017')                   ->sum('total');     return ['total'=>$total]; } 

if have 1 data order in $orders array, spent 4 second display data

if have 10 data order in $orders array, spent 4 second x 10 data order = 40 second display data

it's long

how long if has 1 thousand of data?

how can solve problem?


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -