Browse Source

fix: filter statistic discount given

Muhammad Iqbal Afandi 3 years ago
parent
commit
3776350c96
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      app/Http/Controllers/DashboardController.php

+ 7
- 1
app/Http/Controllers/DashboardController.php View File

@@ -33,7 +33,13 @@ class DashboardController extends Controller
33 33
 
34 34
         $products = Product::get();
35 35
 
36
-        $transactionDiscount = Transaction::whereMonth('created_at', date('m'))->whereNotIn('discount', [0])->get();
36
+        if (request()->user()->outlet_id !== null) {
37
+            request()->merge(['outlet' => request()->user()->outlet_id]);
38
+        }
39
+        $transactionDiscount = Transaction::filter(request()->only('outlet'))
40
+            ->whereMonth('created_at', date('m'))
41
+            ->whereNotIn('discount', [0])
42
+            ->get();
37 43
 
38 44
         $transactionChart = Transaction::get()
39 45
             ->groupBy([