@@ -23,7 +23,7 @@ |
||
| 23 | 23 | |
| 24 | 24 | //$this->app->register(APAnalyticsEventServiceProvider::class); |
| 25 | 25 | |
| 26 | - $this->app->singleton('apanalytics', function () { |
|
| 26 | + $this->app->singleton('apanalytics', function() { |
|
| 27 | 27 | return new APAnalytics(); |
| 28 | 28 | }); |
| 29 | 29 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | public function broadcastOn() |
| 45 | 45 | { |
| 46 | - $postEvent = in_array($this->collection, config('apanalytics.format_collections')); |
|
| 46 | + $postEvent = in_array($this->collection, config('apanalytics.format_collections')); |
|
| 47 | 47 | |
| 48 | 48 | if ($postEvent) { |
| 49 | 49 | return new PresenceChannel("analytics.{$this->collection}.{$this->basename}.{$this->itemId}"); |
@@ -4,14 +4,14 @@ discard block |
||
| 4 | 4 | use Illuminate\Support\Carbon; |
| 5 | 5 | use MongoDB\BSON\UTCDateTime; |
| 6 | 6 | |
| 7 | -if (! function_exists('analytics')) { |
|
| 7 | +if (!function_exists('analytics')) { |
|
| 8 | 8 | function analytics(): APAnalytics |
| 9 | 9 | { |
| 10 | 10 | return app(APAnalytics::class); |
| 11 | 11 | } |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -if (! function_exists('trackEvent')) { |
|
| 14 | +if (!function_exists('trackEvent')) { |
|
| 15 | 15 | /** |
| 16 | 16 | * Access event dispatch of event tracker direct. |
| 17 | 17 | * @param mixed $event |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -if (! function_exists('showEvents')) { |
|
| 29 | +if (!function_exists('showEvents')) { |
|
| 30 | 30 | /** |
| 31 | 31 | * Access event dispatch of event tracker direct. |
| 32 | 32 | * @param mixed $event |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -if (! function_exists('is_countable')) { |
|
| 47 | +if (!function_exists('is_countable')) { |
|
| 48 | 48 | function is_countable($c) |
| 49 | 49 | { |
| 50 | 50 | return is_array($c) || $c instanceof Countable; |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | -if (! function_exists('mongoTime')) { |
|
| 54 | +if (!function_exists('mongoTime')) { |
|
| 55 | 55 | /** |
| 56 | 56 | * Returns time in MongoDb Time. |
| 57 | 57 | * @param null|mixed $time |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | -if (! function_exists('valid_json')) { |
|
| 67 | +if (!function_exists('valid_json')) { |
|
| 68 | 68 | function valid_json($value) |
| 69 | 69 | { |
| 70 | - if (! is_string($value)) { |
|
| 70 | + if (!is_string($value)) { |
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | return true; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - if (! $user) { |
|
| 24 | + if (!$user) { |
|
| 25 | 25 | return false; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -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"; |
@@ -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 | |