| @@ -107,7 +107,7 @@ | ||
| 107 | 107 | } | 
| 108 | 108 | |
| 109 | 109 | // Basic created ie user | 
| 110 | -                    if (! $postEvent && $collection != 'visits') { | |
| 110 | +                    if (!$postEvent && $collection != 'visits') { | |
| 111 | 111 |                          foreach ($items as $item) { | 
| 112 | 112 | $basename = strtolower(Str::singular($collection)); | 
| 113 | 113 |                              $basenameId = "{$basename}_id"; | 
| @@ -66,9 +66,9 @@ discard block | ||
| 66 | 66 | $filters = valid_json($filters) ? json_decode($filters) : $filters; | 
| 67 | 67 | $intervalFormat = '%Y-%m-%dT%H'; | 
| 68 | 68 | $aggregate = []; | 
| 69 | - $model = $this->namespace . Str::studly(Str::singular($collection)) . 'Analytic'; | |
| 69 | + $model = $this->namespace.Str::studly(Str::singular($collection)).'Analytic'; | |
| 70 | 70 | |
| 71 | -        if (! class_exists($model)) { | |
| 71 | +        if (!class_exists($model)) { | |
| 72 | 72 |              throw new InvalidArgumentException("Model {$model} does not exist."); | 
| 73 | 73 | } | 
| 74 | 74 | |
| @@ -115,7 +115,7 @@ discard block | ||
| 115 | 115 | $intervalFormat = '%Y-%m'; | 
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | - $aggregate[] = [ | |
| 118 | + $aggregate[] = [ | |
| 119 | 119 | '$group' => [ | 
| 120 | 120 | '_id' => [ | 
| 121 | 121 | '$dateToString' => ['date' => '$created_at', 'format' => $intervalFormat], | 
| @@ -144,12 +144,12 @@ discard block | ||
| 144 | 144 | $nested = Str::contains($groupBy, '.'); | 
| 145 | 145 | |
| 146 | 146 |              if ($nested) { | 
| 147 | - $aggregate[] = ['$unwind' => '$' . Str::before($groupBy, '.')]; | |
| 147 | + $aggregate[] = ['$unwind' => '$'.Str::before($groupBy, '.')]; | |
| 148 | 148 | } | 
| 149 | 149 | |
| 150 | - $aggregate[] = [ | |
| 150 | + $aggregate[] = [ | |
| 151 | 151 | '$group' => [ | 
| 152 | - '_id' => '$' . $groupBy, | |
| 152 | + '_id' => '$'.$groupBy, | |
| 153 | 153 | 'count' => [ | 
| 154 | 154 | '$sum' => 1, | 
| 155 | 155 | ], | 
| @@ -167,8 +167,8 @@ discard block | ||
| 167 | 167 | ]; | 
| 168 | 168 | } | 
| 169 | 169 | |
| 170 | -        $data = $model::raw(function ($collection) use ($matchArray, $interval, $aggregate, $groupBy) { | |
| 171 | -            if ($interval == 'count' && ! $groupBy) { | |
| 170 | +        $data = $model::raw(function($collection) use ($matchArray, $interval, $aggregate, $groupBy) { | |
| 171 | +            if ($interval == 'count' && !$groupBy) { | |
| 172 | 172 | return $collection->count($matchArray); | 
| 173 | 173 | } | 
| 174 | 174 | |
| @@ -189,11 +189,11 @@ discard block | ||
| 189 | 189 | */ | 
| 190 | 190 | private function toModels($data, $model = null) | 
| 191 | 191 |      { | 
| 192 | -        if (! $model) { | |
| 192 | +        if (!$model) { | |
| 193 | 193 | $model = '\Jenssegers\Mongodb\Eloquent\Model'; | 
| 194 | 194 | } | 
| 195 | 195 | |
| 196 | -        if (! class_exists($model)) { | |
| 196 | +        if (!class_exists($model)) { | |
| 197 | 197 |              throw new InvalidArgumentException("Model {$model} does not exist."); | 
| 198 | 198 | } | 
| 199 | 199 | |
| @@ -230,7 +230,7 @@ discard block | ||
| 230 | 230 | return true; | 
| 231 | 231 | } | 
| 232 | 232 | |
| 233 | -        if (! $user) { | |
| 233 | +        if (!$user) { | |
| 234 | 234 | return false; | 
| 235 | 235 | } | 
| 236 | 236 | |
| @@ -239,13 +239,13 @@ discard block | ||
| 239 | 239 |          if (count($modelsToCheck)) { | 
| 240 | 240 |              foreach ($modelsToCheck as $model) { | 
| 241 | 241 | $modelName = Str::studly(Str::singular($model)); | 
| 242 | - $modelId = Arr::get($filterArray, strtolower($modelName) . '.id'); | |
| 243 | - $modelClass = $this->namespace . $modelName; | |
| 242 | + $modelId = Arr::get($filterArray, strtolower($modelName).'.id'); | |
| 243 | + $modelClass = $this->namespace.$modelName; | |
| 244 | 244 | |
| 245 | 245 |                  if ($modelId) { | 
| 246 | 246 | $model = $modelClass::find($modelId); | 
| 247 | 247 | |
| 248 | -                    if ($model && ! $model->canViewAnalytic($user)) { | |
| 248 | +                    if ($model && !$model->canViewAnalytic($user)) { | |
| 249 | 249 | return false; | 
| 250 | 250 | } | 
| 251 | 251 | } |