@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $aggregate = []; |
66 | 66 | $model = $this->namespace.Str::studly(Str::singular($collection)).'Analytic'; |
67 | 67 | |
68 | - if (! class_exists($model)) { |
|
68 | + if (!class_exists($model)) { |
|
69 | 69 | throw new InvalidArgumentException("Model {$model} does not exist."); |
70 | 70 | } |
71 | 71 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - if (! app()->runningInConsole()) { |
|
88 | + if (!app()->runningInConsole()) { |
|
89 | 89 | abort_unless(auth()->check() && auth()->user()->can('view', [(new $model), $matchArray]), 403, 'You dont have permission to view these analytics'); |
90 | 90 | } |
91 | 91 | |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | if ($distinct) { |
105 | - $aggregate[] = [ |
|
105 | + $aggregate[] = [ |
|
106 | 106 | '$group' => [ |
107 | - '_id' => '$' . $distinct, |
|
107 | + '_id' => '$'.$distinct, |
|
108 | 108 | 'created_at' => [ |
109 | 109 | '$last' => '$created_at', |
110 | 110 | ], |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $intervalFormat = '%Y-%m'; |
126 | 126 | } |
127 | 127 | |
128 | - $aggregate[] = [ |
|
128 | + $aggregate[] = [ |
|
129 | 129 | '$group' => [ |
130 | 130 | '_id' => [ |
131 | 131 | '$dateToString' => ['date' => '$created_at', 'format' => $intervalFormat], |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $aggregate[] = ['$unwind' => '$'.Str::before($groupBy, '.')]; |
158 | 158 | } |
159 | 159 | |
160 | - $aggregate[] = [ |
|
160 | + $aggregate[] = [ |
|
161 | 161 | '$group' => [ |
162 | 162 | '_id' => '$'.$groupBy, |
163 | 163 | 'count' => [ |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | ]; |
178 | 178 | } |
179 | 179 | |
180 | - $data = $model::raw(function ($collection) use ($matchArray, $interval, $aggregate, $groupBy) { |
|
181 | - if ($interval == 'count' && ! $groupBy) { |
|
180 | + $data = $model::raw(function($collection) use ($matchArray, $interval, $aggregate, $groupBy) { |
|
181 | + if ($interval == 'count' && !$groupBy) { |
|
182 | 182 | return $collection->count($matchArray); |
183 | 183 | } |
184 | 184 |