@@ -19,7 +19,7 @@ |
||
| 19 | 19 | * @var array Relations |
| 20 | 20 | */ |
| 21 | 21 | public $belongsTo = [ |
| 22 | - 'user' => ['RainLab\User\Models\User'] |
|
| 22 | + 'user' => [ 'RainLab\User\Models\User' ] |
|
| 23 | 23 | ]; |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | public function render() |
| 22 | 22 | { |
| 23 | 23 | try { |
| 24 | - $this->vars['all'] = $this->getCounts()['all']; |
|
| 25 | - $this->vars['counts'] = $this->getCounts()['counts']; |
|
| 24 | + $this->vars[ 'all' ] = $this->getCounts()[ 'all' ]; |
|
| 25 | + $this->vars[ 'counts' ] = $this->getCounts()[ 'counts' ]; |
|
| 26 | 26 | |
| 27 | 27 | } catch (Exception $ex) { |
| 28 | - $this->vars['error'] = $ex->getMessage(); |
|
| 29 | - $this->vars['all'] = 0; |
|
| 30 | - $this->vars['counts'] = []; |
|
| 28 | + $this->vars[ 'error' ] = $ex->getMessage(); |
|
| 29 | + $this->vars[ 'all' ] = 0; |
|
| 30 | + $this->vars[ 'counts' ] = [ ]; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | return $this->makePartial('widget'); |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $log = AccessLog::all()->groupBy('user_id'); |
| 62 | 62 | |
| 63 | - $counts = []; |
|
| 63 | + $counts = [ ]; |
|
| 64 | 64 | $all = 0; |
| 65 | 65 | foreach ($log as $l) { |
| 66 | - $first = $l[0]; |
|
| 66 | + $first = $l[ 0 ]; |
|
| 67 | 67 | $user = $first->user; |
| 68 | 68 | $size = sizeof($l); |
| 69 | - $counts[] = [ |
|
| 69 | + $counts[ ] = [ |
|
| 70 | 70 | 'size' => $size, |
| 71 | 71 | 'id' => $first->user_id, |
| 72 | 72 | 'name' => $user->username |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | public function render() |
| 24 | 24 | { |
| 25 | 25 | try { |
| 26 | - $this->vars['all'] = $this->loadData(); |
|
| 26 | + $this->vars[ 'all' ] = $this->loadData(); |
|
| 27 | 27 | } |
| 28 | 28 | catch (Exception $ex) { |
| 29 | - $this->vars['error'] = $ex->getMessage(); |
|
| 30 | - $this->vars['all'] = ''; |
|
| 29 | + $this->vars[ 'error' ] = $ex->getMessage(); |
|
| 30 | + $this->vars[ 'all' ] = ''; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | return $this->makePartial('widget'); |
@@ -61,31 +61,31 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $days = $this->property('days'); |
| 63 | 63 | if (!$days) { |
| 64 | - throw new ApplicationException('Invalid days value: ' . $days); |
|
| 64 | + throw new ApplicationException('Invalid days value: '.$days); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // all accesses for last month |
| 68 | 68 | $items = AccessLog::where('created_at', '>=', Carbon::now()->subDays($days)->format('Y-m-d'))->get(); |
| 69 | 69 | |
| 70 | 70 | // parse data |
| 71 | - $all = []; |
|
| 71 | + $all = [ ]; |
|
| 72 | 72 | foreach ($items as $item) |
| 73 | 73 | { |
| 74 | 74 | // date |
| 75 | 75 | $timestamp = strtotime($item->created_at) * 1000; |
| 76 | 76 | $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d'); |
| 77 | 77 | |
| 78 | - if (isset($all[$day])) { |
|
| 79 | - $all[$day][1]++; |
|
| 78 | + if (isset($all[ $day ])) { |
|
| 79 | + $all[ $day ][ 1 ]++; |
|
| 80 | 80 | } else { |
| 81 | - $all[$day] = [$timestamp, 1]; |
|
| 81 | + $all[ $day ] = [ $timestamp, 1 ]; |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // count accessess for each day |
| 86 | - $all_render = []; |
|
| 86 | + $all_render = [ ]; |
|
| 87 | 87 | foreach ($all as $a) { |
| 88 | - $all_render[] = [$a[0], $a[1]]; |
|
| 88 | + $all_render[ ] = [ $a[ 0 ], $a[ 1 ] ]; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return str_replace('"', '', substr(substr(json_encode($all_render), 1), 0, -1)); |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | public function render() |
| 23 | 23 | { |
| 24 | 24 | try { |
| 25 | - $this->vars['registrations'] = $this->loadData(); |
|
| 25 | + $this->vars[ 'registrations' ] = $this->loadData(); |
|
| 26 | 26 | |
| 27 | 27 | } catch (Exception $ex) { |
| 28 | - $this->vars['error'] = $ex->getMessage(); |
|
| 29 | - $this->vars['registrations'] = []; |
|
| 28 | + $this->vars[ 'error' ] = $ex->getMessage(); |
|
| 29 | + $this->vars[ 'registrations' ] = [ ]; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return $this->makePartial('widget'); |
@@ -55,31 +55,31 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $days = $this->property('days'); |
| 57 | 57 | if (!$days) { |
| 58 | - throw new ApplicationException('Invalid days value: ' . $days); |
|
| 58 | + throw new ApplicationException('Invalid days value: '.$days); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // all accesses for last month |
| 62 | 62 | $items = User::where('created_at', '>=', Carbon::now()->subDays($days)->format('Y-m-d'))->get(); |
| 63 | 63 | |
| 64 | 64 | // parse data |
| 65 | - $all = []; |
|
| 65 | + $all = [ ]; |
|
| 66 | 66 | foreach ($items as $item) |
| 67 | 67 | { |
| 68 | 68 | // date |
| 69 | 69 | $timestamp = strtotime($item->created_at) * 1000; |
| 70 | 70 | $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d'); |
| 71 | 71 | |
| 72 | - if (isset($all[$day])) { |
|
| 73 | - $all[$day][1]++; |
|
| 72 | + if (isset($all[ $day ])) { |
|
| 73 | + $all[ $day ][ 1 ]++; |
|
| 74 | 74 | } else { |
| 75 | - $all[$day] = [$timestamp, 1]; |
|
| 75 | + $all[ $day ] = [ $timestamp, 1 ]; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // count all |
| 80 | - $all_render = []; |
|
| 80 | + $all_render = [ ]; |
|
| 81 | 81 | foreach ($all as $a) { |
| 82 | - $all_render[] = [$a[0], $a[1]]; |
|
| 82 | + $all_render[ ] = [ $a[ 0 ], $a[ 1 ] ]; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | return $all_render; |
@@ -23,15 +23,15 @@ discard block |
||
| 23 | 23 | public function render() |
| 24 | 24 | { |
| 25 | 25 | try { |
| 26 | - $this->vars['all'] = $this->loadData()['all']; |
|
| 27 | - $this->vars['rows'] = $this->loadData()['user_rows']; |
|
| 28 | - $this->vars['users'] = $this->loadData()['users']; |
|
| 26 | + $this->vars[ 'all' ] = $this->loadData()[ 'all' ]; |
|
| 27 | + $this->vars[ 'rows' ] = $this->loadData()[ 'user_rows' ]; |
|
| 28 | + $this->vars[ 'users' ] = $this->loadData()[ 'users' ]; |
|
| 29 | 29 | |
| 30 | 30 | } catch (Exception $ex) { |
| 31 | - $this->vars['error'] = $ex->getMessage(); |
|
| 32 | - $this->vars['all'] = 0; |
|
| 33 | - $this->vars['users'] = []; |
|
| 34 | - $this->vars['rows'] = []; |
|
| 31 | + $this->vars[ 'error' ] = $ex->getMessage(); |
|
| 32 | + $this->vars[ 'all' ] = 0; |
|
| 33 | + $this->vars[ 'users' ] = [ ]; |
|
| 34 | + $this->vars[ 'rows' ] = [ ]; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | return $this->makePartial('widget'); |
@@ -60,55 +60,55 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $days = $this->property('days'); |
| 62 | 62 | if (!$days) { |
| 63 | - throw new ApplicationException('Invalid days value: ' . $days); |
|
| 63 | + throw new ApplicationException('Invalid days value: '.$days); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // all accesses for last month |
| 67 | 67 | $items = AccessLog::where('created_at', '>=', Carbon::now()->subDays($days)->format('Y-m-d'))->get(); |
| 68 | 68 | |
| 69 | 69 | // parse data |
| 70 | - $all = []; |
|
| 71 | - $users = []; |
|
| 72 | - $user_rows = []; |
|
| 70 | + $all = [ ]; |
|
| 71 | + $users = [ ]; |
|
| 72 | + $user_rows = [ ]; |
|
| 73 | 73 | foreach ($items as $item) |
| 74 | 74 | { |
| 75 | 75 | // user |
| 76 | 76 | $user_id = $item->user_id ? $item->user_id : 0; |
| 77 | - $users[$user_id] = $user_id > 0 ? User::find($user_id) : $this->getDeletedFakeUser(); |
|
| 77 | + $users[ $user_id ] = $user_id > 0 ? User::find($user_id) : $this->getDeletedFakeUser(); |
|
| 78 | 78 | |
| 79 | 79 | // date |
| 80 | 80 | $timestamp = strtotime($item->created_at) * 1000; |
| 81 | 81 | $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d'); |
| 82 | 82 | |
| 83 | - if (isset($user_rows[$user_id][$day])) { |
|
| 84 | - $user_rows[$user_id][$day][1]++; |
|
| 83 | + if (isset($user_rows[ $user_id ][ $day ])) { |
|
| 84 | + $user_rows[ $user_id ][ $day ][ 1 ]++; |
|
| 85 | 85 | } else { |
| 86 | - $user_rows[$user_id][$day] = [$timestamp, 1]; |
|
| 86 | + $user_rows[ $user_id ][ $day ] = [ $timestamp, 1 ]; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if (isset($all[$day])) { |
|
| 90 | - $all[$day][1]++; |
|
| 89 | + if (isset($all[ $day ])) { |
|
| 90 | + $all[ $day ][ 1 ]++; |
|
| 91 | 91 | } else { |
| 92 | - $all[$day] = [$timestamp, 1]; |
|
| 92 | + $all[ $day ] = [ $timestamp, 1 ]; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // transform user line to json |
| 97 | 97 | foreach ($user_rows as $key => $user_row) { |
| 98 | - $rows = []; |
|
| 99 | - foreach($user_row as $row) { |
|
| 100 | - $rows[] = [ |
|
| 101 | - $row[0], |
|
| 102 | - $row[1], |
|
| 98 | + $rows = [ ]; |
|
| 99 | + foreach ($user_row as $row) { |
|
| 100 | + $rows[ ] = [ |
|
| 101 | + $row[ 0 ], |
|
| 102 | + $row[ 1 ], |
|
| 103 | 103 | ]; |
| 104 | 104 | } |
| 105 | - $user_rows[$key] = $rows; |
|
| 105 | + $user_rows[ $key ] = $rows; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // count all |
| 109 | - $all_render = []; |
|
| 109 | + $all_render = [ ]; |
|
| 110 | 110 | foreach ($all as $a) { |
| 111 | - $all_render[] = [$a[0], $a[1]]; |
|
| 111 | + $all_render[ ] = [ $a[ 0 ], $a[ 1 ] ]; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | return [ |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | /** |
| 13 | 13 | * @var array Plugin dependencies |
| 14 | 14 | */ |
| 15 | - public $require = ['RainLab.User']; |
|
| 15 | + public $require = [ 'RainLab.User' ]; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Returns information about this plugin. |