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
Post a Comment