@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | $filters = valid_json($filters) ? json_decode($filters) : $filters; |
64 | 64 | $intervalFormat = '%Y-%m-%dT%H'; |
65 | 65 | $aggregate = []; |
66 | - $model = $this->namespace . Str::studly(Str::singular($collection)) . 'Analytic'; |
|
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 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $intervalFormat = '%Y-%m'; |
113 | 113 | } |
114 | 114 | |
115 | - $aggregate[] = [ |
|
115 | + $aggregate[] = [ |
|
116 | 116 | '$group' => [ |
117 | 117 | '_id' => [ |
118 | 118 | '$dateToString' => ['date' => '$created_at', 'format' => $intervalFormat], |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | $nested = Str::contains($groupBy, '.'); |
142 | 142 | |
143 | 143 | if ($nested) { |
144 | - $aggregate[] = ['$unwind' => '$' . Str::before($groupBy, '.')]; |
|
144 | + $aggregate[] = ['$unwind' => '$'.Str::before($groupBy, '.')]; |
|
145 | 145 | } |
146 | 146 | |
147 | - $aggregate[] = [ |
|
147 | + $aggregate[] = [ |
|
148 | 148 | '$group' => [ |
149 | - '_id' => '$' . $groupBy, |
|
149 | + '_id' => '$'.$groupBy, |
|
150 | 150 | 'count' => [ |
151 | 151 | '$sum' => 1, |
152 | 152 | ], |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | ]; |
165 | 165 | } |
166 | 166 | |
167 | - $data = $model::raw(function ($collection) use ($matchArray, $interval, $aggregate, $groupBy) { |
|
168 | - if ($interval == 'count' && ! $groupBy) { |
|
167 | + $data = $model::raw(function($collection) use ($matchArray, $interval, $aggregate, $groupBy) { |
|
168 | + if ($interval == 'count' && !$groupBy) { |
|
169 | 169 | return $collection->count($matchArray); |
170 | 170 | } |
171 | 171 |