@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | public function render() |
21 | 21 | { |
22 | 22 | try { |
23 | - $this->vars['registrations'] = $this->loadData(); |
|
23 | + $this->vars[ 'registrations' ] = $this->loadData(); |
|
24 | 24 | |
25 | 25 | } catch (Exception $ex) { |
26 | - $this->vars['error'] = $ex->getMessage(); |
|
27 | - $this->vars['registrations'] = []; |
|
26 | + $this->vars[ 'error' ] = $ex->getMessage(); |
|
27 | + $this->vars[ 'registrations' ] = [ ]; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | return $this->makePartial('widget'); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $days = $this->property('days'); |
55 | 55 | if (!$days) { |
56 | - throw new ApplicationException('Invalid days value: ' . $days); |
|
56 | + throw new ApplicationException('Invalid days value: '.$days); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // all accesses for last month |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | // we need at least two days, to display chart |
66 | 66 | if (sizeof($all) == 1) { |
67 | 67 | $day = reset($all); |
68 | - $date = Carbon::createFromFormat('Y-m-d', $day['date'])->subDays(1); |
|
68 | + $date = Carbon::createFromFormat('Y-m-d', $day[ 'date' ])->subDays(1); |
|
69 | 69 | $dateFormated = $date->format('Y-m-d'); |
70 | - $all[$dateFormated] = [ |
|
70 | + $all[ $dateFormated ] = [ |
|
71 | 71 | 'timestamp' => $date->timestamp * 1000, |
72 | 72 | 'date' => $dateFormated, |
73 | 73 | 'count' => 0, |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | // count all |
78 | - $all_render = []; |
|
78 | + $all_render = [ ]; |
|
79 | 79 | foreach ($all as $a) { |
80 | - $all_render[] = [$a['timestamp'], $a['count']]; |
|
80 | + $all_render[ ] = [ $a[ 'timestamp' ], $a[ 'count' ] ]; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | return $all_render; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | private function sortItemsToDays($items) |
94 | 94 | { |
95 | - $all = []; |
|
95 | + $all = [ ]; |
|
96 | 96 | |
97 | 97 | foreach ($items as $item) |
98 | 98 | { |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d'); |
102 | 102 | |
103 | 103 | // init empty day |
104 | - if (!isset($all[$day])) { |
|
105 | - $all[$day] = [ |
|
104 | + if (!isset($all[ $day ])) { |
|
105 | + $all[ $day ] = [ |
|
106 | 106 | 'timestamp' => $timestamp, |
107 | 107 | 'date' => $day, |
108 | 108 | 'count' => 0, |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | // increase count |
113 | - $all[$day]['count']++; |
|
113 | + $all[ $day ][ 'count' ]++; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return $all; |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | public function render() |
22 | 22 | { |
23 | 23 | try { |
24 | - $this->vars['all'] = $this->loadData(); |
|
24 | + $this->vars[ 'all' ] = $this->loadData(); |
|
25 | 25 | } |
26 | 26 | catch (Exception $ex) { |
27 | - $this->vars['error'] = $ex->getMessage(); |
|
28 | - $this->vars['all'] = ''; |
|
27 | + $this->vars[ 'error' ] = $ex->getMessage(); |
|
28 | + $this->vars[ 'all' ] = ''; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | return $this->makePartial('widget'); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | $days = $this->property('days'); |
61 | 61 | if (!$days) { |
62 | - throw new ApplicationException('Invalid days value: ' . $days); |
|
62 | + throw new ApplicationException('Invalid days value: '.$days); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // all accesses for last month |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | // we need at least two days, to display chart |
72 | 72 | if (sizeof($all) == 1) { |
73 | 73 | $day = reset($all); |
74 | - $date = Carbon::createFromFormat('Y-m-d', $day['date'])->subDays(1); |
|
74 | + $date = Carbon::createFromFormat('Y-m-d', $day[ 'date' ])->subDays(1); |
|
75 | 75 | $dateFormated = $date->format('Y-m-d'); |
76 | - $all[$dateFormated] = [ |
|
76 | + $all[ $dateFormated ] = [ |
|
77 | 77 | 'timestamp' => $date->timestamp * 1000, |
78 | 78 | 'date' => $dateFormated, |
79 | 79 | 'count' => 0, |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // count accessess for each day |
84 | - $all_render = []; |
|
84 | + $all_render = [ ]; |
|
85 | 85 | foreach ($all as $a) { |
86 | - $all_render[] = [$a['timestamp'], $a['count']]; |
|
86 | + $all_render[ ] = [ $a[ 'timestamp' ], $a[ 'count' ] ]; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | return $all_render; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | private function sortItemsToDays($items) |
100 | 100 | { |
101 | - $all = []; |
|
101 | + $all = [ ]; |
|
102 | 102 | |
103 | 103 | foreach ($items as $item) |
104 | 104 | { |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d'); |
108 | 108 | |
109 | 109 | // init empty day |
110 | - if (!isset($all[$day])) { |
|
111 | - $all[$day] = [ |
|
110 | + if (!isset($all[ $day ])) { |
|
111 | + $all[ $day ] = [ |
|
112 | 112 | 'timestamp' => $timestamp, |
113 | 113 | 'date' => $day, |
114 | 114 | 'count' => 0, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | // increase count |
119 | - $all[$day]['count']++; |
|
119 | + $all[ $day ][ 'count' ]++; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return $all; |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | public function render() |
22 | 22 | { |
23 | 23 | try { |
24 | - $this->vars['all'] = $this->loadData()['all']; |
|
25 | - $this->vars['rows'] = $this->loadData()['user_rows']; |
|
26 | - $this->vars['users'] = $this->loadData()['users']; |
|
24 | + $this->vars[ 'all' ] = $this->loadData()[ 'all' ]; |
|
25 | + $this->vars[ 'rows' ] = $this->loadData()[ 'user_rows' ]; |
|
26 | + $this->vars[ 'users' ] = $this->loadData()[ 'users' ]; |
|
27 | 27 | |
28 | 28 | } catch (Exception $ex) { |
29 | - $this->vars['error'] = $ex->getMessage(); |
|
30 | - $this->vars['all'] = 0; |
|
31 | - $this->vars['users'] = []; |
|
32 | - $this->vars['rows'] = []; |
|
29 | + $this->vars[ 'error' ] = $ex->getMessage(); |
|
30 | + $this->vars[ 'all' ] = 0; |
|
31 | + $this->vars[ 'users' ] = [ ]; |
|
32 | + $this->vars[ 'rows' ] = [ ]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $this->makePartial('widget'); |
@@ -58,35 +58,35 @@ discard block |
||
58 | 58 | { |
59 | 59 | $days = $this->property('days'); |
60 | 60 | if (!$days) { |
61 | - throw new ApplicationException('Invalid days value: ' . $days); |
|
61 | + throw new ApplicationException('Invalid days value: '.$days); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // all accesses for last month |
65 | 65 | $items = AccessLog::where('created_at', '>=', Carbon::now()->subDays($days)->format('Y-m-d'))->get(); |
66 | 66 | |
67 | 67 | // parse data |
68 | - $all = []; |
|
69 | - $users = []; |
|
70 | - $user_rows = []; |
|
68 | + $all = [ ]; |
|
69 | + $users = [ ]; |
|
70 | + $user_rows = [ ]; |
|
71 | 71 | foreach ($items as $item) |
72 | 72 | { |
73 | 73 | // user |
74 | 74 | $user_id = $item->user_id ? $item->user_id : 0; |
75 | - $users[$user_id] = $user_id > 0 ? User::find($user_id) : $this->getDeletedFakeUser(); |
|
75 | + $users[ $user_id ] = $user_id > 0 ? User::find($user_id) : $this->getDeletedFakeUser(); |
|
76 | 76 | |
77 | 77 | // date |
78 | 78 | $timestamp = strtotime($item->created_at) * 1000; |
79 | 79 | $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d'); |
80 | 80 | |
81 | - if (isset($user_rows[$user_id][$day])) { |
|
82 | - $user_rows[$user_id][$day][1]++; |
|
81 | + if (isset($user_rows[ $user_id ][ $day ])) { |
|
82 | + $user_rows[ $user_id ][ $day ][ 1 ]++; |
|
83 | 83 | } else { |
84 | - $user_rows[$user_id][$day] = [$timestamp, 1]; |
|
84 | + $user_rows[ $user_id ][ $day ] = [ $timestamp, 1 ]; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // init empty day |
88 | - if (!isset($all[$day])) { |
|
89 | - $all[$day] = [ |
|
88 | + if (!isset($all[ $day ])) { |
|
89 | + $all[ $day ] = [ |
|
90 | 90 | 'timestamp' => $timestamp, |
91 | 91 | 'date' => $day, |
92 | 92 | 'count' => 0, |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | // increase count |
97 | - $all[$day]['count']++; |
|
97 | + $all[ $day ][ 'count' ]++; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | // we need at least two days, to display chart |
101 | 101 | if (sizeof($all) == 1) { |
102 | 102 | $day = reset($all); |
103 | - $date = Carbon::createFromFormat('Y-m-d', $day['date'])->subDays(1); |
|
103 | + $date = Carbon::createFromFormat('Y-m-d', $day[ 'date' ])->subDays(1); |
|
104 | 104 | $dateFormated = $date->format('Y-m-d'); |
105 | - $all[$dateFormated] = [ |
|
105 | + $all[ $dateFormated ] = [ |
|
106 | 106 | 'timestamp' => $date->timestamp * 1000, |
107 | 107 | 'date' => $dateFormated, |
108 | 108 | 'count' => 0, |
@@ -112,27 +112,27 @@ discard block |
||
112 | 112 | // transform user line to json |
113 | 113 | foreach ($user_rows as $key => $user_row) |
114 | 114 | { |
115 | - $rows = []; |
|
116 | - foreach($user_row as $row) { |
|
117 | - $rows[] = [ |
|
118 | - $row[0], |
|
119 | - $row[1], |
|
115 | + $rows = [ ]; |
|
116 | + foreach ($user_row as $row) { |
|
117 | + $rows[ ] = [ |
|
118 | + $row[ 0 ], |
|
119 | + $row[ 1 ], |
|
120 | 120 | ]; |
121 | 121 | } |
122 | 122 | |
123 | 123 | // we need at least two days, to display chart |
124 | 124 | if (sizeof($rows) == 1) { |
125 | 125 | $first = reset($rows); |
126 | - $rows[] = [$first[0] - 86400000, 0]; |
|
126 | + $rows[ ] = [ $first[ 0 ] - 86400000, 0 ]; |
|
127 | 127 | } |
128 | 128 | |
129 | - $user_rows[$key] = $rows; |
|
129 | + $user_rows[ $key ] = $rows; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // count all |
133 | - $all_render = []; |
|
133 | + $all_render = [ ]; |
|
134 | 134 | foreach ($all as $a) { |
135 | - $all_render[] = [$a['timestamp'], $a['count']]; |
|
135 | + $all_render[ ] = [ $a[ 'timestamp' ], $a[ 'count' ] ]; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return [ |