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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to implement an entity bound odata action in olingo v4.3 -