@@ -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 | |
@@ -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 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $intervalFormat = '%Y-%m'; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $aggregate[] = [ |
|
| 117 | + $aggregate[] = [ |
|
| 118 | 118 | '$group' => [ |
| 119 | 119 | '_id' => [ |
| 120 | 120 | '$dateToString' => ['date' => '$created_at', 'format' => $intervalFormat], |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | $nested = Str::contains($groupBy, '.'); |
| 144 | 144 | |
| 145 | 145 | if ($nested) { |
| 146 | - $aggregate[] = ['$unwind' => '$' . Str::before($groupBy, '.')]; |
|
| 146 | + $aggregate[] = ['$unwind' => '$'.Str::before($groupBy, '.')]; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $aggregate[] = [ |
|
| 149 | + $aggregate[] = [ |
|
| 150 | 150 | '$group' => [ |
| 151 | - '_id' => '$' . $groupBy, |
|
| 151 | + '_id' => '$'.$groupBy, |
|
| 152 | 152 | 'count' => [ |
| 153 | 153 | '$sum' => 1, |
| 154 | 154 | ], |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | ]; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $data = $model::raw(function ($collection) use ($matchArray, $interval, $aggregate, $groupBy) { |
|
| 170 | - if ($interval == 'count' && ! $groupBy) { |
|
| 169 | + $data = $model::raw(function($collection) use ($matchArray, $interval, $aggregate, $groupBy) { |
|
| 170 | + if ($interval == 'count' && !$groupBy) { |
|
| 171 | 171 | return $collection->count($matchArray); |
| 172 | 172 | } |
| 173 | 173 | |