Browse Source

fix: mutation

Muhammad Iqbal Afandi 3 years ago
parent
commit
460d661456
1 changed files with 10 additions and 14 deletions
  1. 10
    14
      app/Services/MutationService.php

+ 10
- 14
app/Services/MutationService.php View File

9
 {
9
 {
10
     public function totalIncome(EloquentCollection $collections)
10
     public function totalIncome(EloquentCollection $collections)
11
     {
11
     {
12
-        foreach ($collections->chunk(100) as $chunk) {
13
-            return $chunk->sum(function ($collect) {
14
-                if ($collect->getRawOriginal('type') == 1) {
15
-                    return $collect->getRawOriginal('amount');
16
-                }
17
-            });
18
-        }
12
+        return $collections->sum(function ($collect) {
13
+            if ($collect->getRawOriginal('type') == 1) {
14
+                return $collect->getRawOriginal('amount');
15
+            }
16
+        });
19
     }
17
     }
20
 
18
 
21
     public function totalExpense(EloquentCollection $collections)
19
     public function totalExpense(EloquentCollection $collections)
22
     {
20
     {
23
-        foreach ($collections->chunk(100) as $chunk) {
24
-            return $chunk->sum(function ($collect) {
25
-                if ($collect->getRawOriginal('type') == 2) {
26
-                    return $collect->getRawOriginal('amount');
27
-                }
28
-            });
29
-        }
21
+        return $collections->sum(function ($collect) {
22
+            if ($collect->getRawOriginal('type') == 2) {
23
+                return $collect->getRawOriginal('amount');
24
+            }
25
+        });
30
     }
26
     }
31
 
27
 
32
     public function totalIncomeAsString(EloquentCollection $collections)
28
     public function totalIncomeAsString(EloquentCollection $collections)