Completed
Push — master ( 8d67df...1d95ec )
by Vojta
02:13
created
reportwidgets/AccessLogChartLineAggregated.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
     public function render()
24 24
     {
25 25
         try {
26
-            $this->vars['all'] = $this->loadData();
26
+            $this->vars[ 'all' ] = $this->loadData();
27 27
         }
28 28
         catch (Exception $ex) {
29
-            $this->vars['error'] = $ex->getMessage();
30
-            $this->vars['all'] = '';
29
+            $this->vars[ 'error' ] = $ex->getMessage();
30
+            $this->vars[ 'all' ] = '';
31 31
         }
32 32
 
33 33
         return $this->makePartial('widget');
@@ -61,31 +61,31 @@  discard block
 block discarded – undo
61 61
     {
62 62
         $days = $this->property('days');
63 63
         if (!$days) {
64
-            throw new ApplicationException('Invalid days value: ' . $days);
64
+            throw new ApplicationException('Invalid days value: '.$days);
65 65
         }
66 66
 
67 67
         // all accesses for last month
68 68
         $items = AccessLog::where('created_at', '>=', Carbon::now()->subDays($days)->format('Y-m-d'))->get();
69 69
 
70 70
         // parse data
71
-        $all = [];
71
+        $all = [ ];
72 72
         foreach ($items as $item)
73 73
         {
74 74
             // date
75 75
             $timestamp = strtotime($item->created_at) * 1000;
76 76
             $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d');
77 77
 
78
-            if (isset($all[$day])) {
79
-                $all[$day][1]++;
78
+            if (isset($all[ $day ])) {
79
+                $all[ $day ][ 1 ]++;
80 80
             } else {
81
-                $all[$day] = [$timestamp, 1];
81
+                $all[ $day ] = [ $timestamp, 1 ];
82 82
             }
83 83
         }
84 84
 
85 85
         // count accessess for each day
86
-        $all_render = [];
86
+        $all_render = [ ];
87 87
         foreach ($all as $a) {
88
-            $all_render[] = [$a[0], $a[1]];
88
+            $all_render[ ] = [ $a[ 0 ], $a[ 1 ] ];
89 89
         }
90 90
 
91 91
         return str_replace('"', '', substr(substr(json_encode($all_render), 1), 0, -1));
Please login to merge, or discard this patch.