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 -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -