@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | |
25 | 25 | public function require($input = null, $msg = null) |
26 | 26 | { |
27 | - if (! $this->input) $this->input = $input; |
|
27 | + if (!$this->input) $this->input = $input; |
|
28 | 28 | |
29 | 29 | $value = $this->value($this->input); |
30 | 30 | |
31 | - if (! $value) { |
|
31 | + if (!$value) { |
|
32 | 32 | |
33 | 33 | $msg = $msg ?: 'This input is required'; |
34 | 34 | |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | |
40 | 40 | public function email($input = null, $msg = null) |
41 | 41 | { |
42 | - if (! $this->input) $this->input = $input; |
|
42 | + if (!$this->input) $this->input = $input; |
|
43 | 43 | |
44 | 44 | $value = $this->value($this->input); |
45 | 45 | |
46 | - if (! filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
46 | + if (!filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
47 | 47 | |
48 | 48 | $msg = $msg ?: sprintf('%s is not valid Email', ucfirst($this->input)); |
49 | 49 | |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | |
55 | 55 | public function number($input = null, $msg = null) |
56 | 56 | { |
57 | - if (! $this->input) $this->input = $input; |
|
57 | + if (!$this->input) $this->input = $input; |
|
58 | 58 | |
59 | 59 | $value = $this->value($this->input); |
60 | 60 | |
61 | 61 | if ($value) { |
62 | 62 | |
63 | - if (! is_numeric($value)) { |
|
63 | + if (!is_numeric($value)) { |
|
64 | 64 | |
65 | 65 | $msg = $msg ?: 'the Input must be number'; |
66 | 66 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | public function text($input = null, $msg = null) |
74 | 74 | { |
75 | - if (! $this->input) $this->input = $input; |
|
75 | + if (!$this->input) $this->input = $input; |
|
76 | 76 | |
77 | 77 | $value = $this->value($this->input); |
78 | 78 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | $valueConfirm = $this->value($input); |
128 | 128 | |
129 | - if ($valuePassword && $valueConfirm ) { |
|
129 | + if ($valuePassword && $valueConfirm) { |
|
130 | 130 | |
131 | 131 | if ($valuePassword !== $valueConfirm) { |
132 | 132 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | public function fails() |
200 | 200 | { |
201 | - return ! empty($this->errors); |
|
201 | + return !empty($this->errors); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | public function getMsgs() |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | public function addError($input, $msg) |
215 | 215 | { |
216 | - if (! $this->checkError($input)) { |
|
216 | + if (!$this->checkError($input)) { |
|
217 | 217 | |
218 | 218 | $this->errors[$input] = $msg; |
219 | 219 | } |
@@ -4,211 +4,211 @@ |
||
4 | 4 | |
5 | 5 | class Validation |
6 | 6 | { |
7 | - private $app; |
|
7 | + private $app; |
|
8 | 8 | |
9 | - private $input; |
|
9 | + private $input; |
|
10 | 10 | |
11 | - private $errors = []; |
|
11 | + private $errors = []; |
|
12 | 12 | |
13 | - public function __construct(Application $app) |
|
14 | - { |
|
15 | - $this->app = $app; |
|
16 | - } |
|
13 | + public function __construct(Application $app) |
|
14 | + { |
|
15 | + $this->app = $app; |
|
16 | + } |
|
17 | 17 | |
18 | - public function input($input) |
|
19 | - { |
|
20 | - $this->input = $input; |
|
18 | + public function input($input) |
|
19 | + { |
|
20 | + $this->input = $input; |
|
21 | 21 | |
22 | - return $this; |
|
23 | - } |
|
22 | + return $this; |
|
23 | + } |
|
24 | 24 | |
25 | - public function require($input = null, $msg = null) |
|
26 | - { |
|
27 | - if (! $this->input) $this->input = $input; |
|
25 | + public function require($input = null, $msg = null) |
|
26 | + { |
|
27 | + if (! $this->input) $this->input = $input; |
|
28 | 28 | |
29 | - $value = $this->value($this->input); |
|
29 | + $value = $this->value($this->input); |
|
30 | 30 | |
31 | - if (! $value) { |
|
31 | + if (! $value) { |
|
32 | 32 | |
33 | - $msg = $msg ?: 'This input is required'; |
|
33 | + $msg = $msg ?: 'This input is required'; |
|
34 | 34 | |
35 | - $this->addError($this->input, $msg); |
|
36 | - } |
|
37 | - return $this; |
|
38 | - } |
|
35 | + $this->addError($this->input, $msg); |
|
36 | + } |
|
37 | + return $this; |
|
38 | + } |
|
39 | 39 | |
40 | - public function email($input = null, $msg = null) |
|
41 | - { |
|
42 | - if (! $this->input) $this->input = $input; |
|
40 | + public function email($input = null, $msg = null) |
|
41 | + { |
|
42 | + if (! $this->input) $this->input = $input; |
|
43 | 43 | |
44 | - $value = $this->value($this->input); |
|
44 | + $value = $this->value($this->input); |
|
45 | 45 | |
46 | - if (! filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
46 | + if (! filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
47 | 47 | |
48 | - $msg = $msg ?: sprintf('%s is not valid Email', ucfirst($this->input)); |
|
48 | + $msg = $msg ?: sprintf('%s is not valid Email', ucfirst($this->input)); |
|
49 | 49 | |
50 | - $this->addError($this->input, $msg); |
|
51 | - } |
|
52 | - return $this; |
|
53 | - } |
|
50 | + $this->addError($this->input, $msg); |
|
51 | + } |
|
52 | + return $this; |
|
53 | + } |
|
54 | 54 | |
55 | - public function number($input = null, $msg = null) |
|
56 | - { |
|
57 | - if (! $this->input) $this->input = $input; |
|
55 | + public function number($input = null, $msg = null) |
|
56 | + { |
|
57 | + if (! $this->input) $this->input = $input; |
|
58 | 58 | |
59 | - $value = $this->value($this->input); |
|
59 | + $value = $this->value($this->input); |
|
60 | 60 | |
61 | - if ($value) { |
|
61 | + if ($value) { |
|
62 | 62 | |
63 | - if (! is_numeric($value)) { |
|
63 | + if (! is_numeric($value)) { |
|
64 | 64 | |
65 | - $msg = $msg ?: 'the Input must be number'; |
|
65 | + $msg = $msg ?: 'the Input must be number'; |
|
66 | 66 | |
67 | - $this->addError($this->input, $msg); |
|
68 | - } |
|
69 | - } |
|
70 | - return $this; |
|
71 | - } |
|
67 | + $this->addError($this->input, $msg); |
|
68 | + } |
|
69 | + } |
|
70 | + return $this; |
|
71 | + } |
|
72 | 72 | |
73 | - public function text($input = null, $msg = null) |
|
74 | - { |
|
75 | - if (! $this->input) $this->input = $input; |
|
73 | + public function text($input = null, $msg = null) |
|
74 | + { |
|
75 | + if (! $this->input) $this->input = $input; |
|
76 | 76 | |
77 | - $value = $this->value($this->input); |
|
77 | + $value = $this->value($this->input); |
|
78 | 78 | |
79 | - if ($value) { |
|
79 | + if ($value) { |
|
80 | 80 | |
81 | - if (is_numeric($value)) { |
|
81 | + if (is_numeric($value)) { |
|
82 | 82 | |
83 | - $msg = $msg ?: 'the Input must be Text'; |
|
83 | + $msg = $msg ?: 'the Input must be Text'; |
|
84 | 84 | |
85 | - $this->addError($this->input, $msg); |
|
86 | - } |
|
87 | - } |
|
88 | - return $this; |
|
89 | - } |
|
85 | + $this->addError($this->input, $msg); |
|
86 | + } |
|
87 | + } |
|
88 | + return $this; |
|
89 | + } |
|
90 | 90 | |
91 | - public function minLen($length, $msg = null) |
|
92 | - { |
|
93 | - $value = $this->value($this->input); |
|
91 | + public function minLen($length, $msg = null) |
|
92 | + { |
|
93 | + $value = $this->value($this->input); |
|
94 | 94 | |
95 | - if ($value) { |
|
95 | + if ($value) { |
|
96 | 96 | |
97 | - if (strlen($value) < $length) { |
|
97 | + if (strlen($value) < $length) { |
|
98 | 98 | |
99 | - $msg = $msg ?: 'This input must be at least ' . $length; |
|
99 | + $msg = $msg ?: 'This input must be at least ' . $length; |
|
100 | 100 | |
101 | - $this->addError($this->input, $msg); |
|
102 | - } |
|
103 | - } |
|
104 | - return $this; |
|
105 | - } |
|
101 | + $this->addError($this->input, $msg); |
|
102 | + } |
|
103 | + } |
|
104 | + return $this; |
|
105 | + } |
|
106 | 106 | |
107 | - public function maxLen($length, $msg = null) |
|
108 | - { |
|
109 | - $value = $this->value($this->input); |
|
107 | + public function maxLen($length, $msg = null) |
|
108 | + { |
|
109 | + $value = $this->value($this->input); |
|
110 | 110 | |
111 | - if ($value) { |
|
111 | + if ($value) { |
|
112 | 112 | |
113 | - if (strlen($value) > $length) { |
|
113 | + if (strlen($value) > $length) { |
|
114 | 114 | |
115 | - $msg = $msg ?: 'This must be ' . $length . ' or fewer'; |
|
115 | + $msg = $msg ?: 'This must be ' . $length . ' or fewer'; |
|
116 | 116 | |
117 | - $this->addError($this->input, $msg); |
|
118 | - } |
|
119 | - } |
|
120 | - return $this; |
|
121 | - } |
|
117 | + $this->addError($this->input, $msg); |
|
118 | + } |
|
119 | + } |
|
120 | + return $this; |
|
121 | + } |
|
122 | 122 | |
123 | - public function match($input, $msg = null) |
|
124 | - { |
|
125 | - $valuePassword = $this->value($this->input); |
|
123 | + public function match($input, $msg = null) |
|
124 | + { |
|
125 | + $valuePassword = $this->value($this->input); |
|
126 | 126 | |
127 | - $valueConfirm = $this->value($input); |
|
127 | + $valueConfirm = $this->value($input); |
|
128 | 128 | |
129 | - if ($valuePassword && $valueConfirm ) { |
|
129 | + if ($valuePassword && $valueConfirm ) { |
|
130 | 130 | |
131 | - if ($valuePassword !== $valueConfirm) { |
|
131 | + if ($valuePassword !== $valueConfirm) { |
|
132 | 132 | |
133 | - $msg = $msg ?: 'Passwords does not match'; |
|
133 | + $msg = $msg ?: 'Passwords does not match'; |
|
134 | 134 | |
135 | - $this->addError('match', $msg); |
|
136 | - } |
|
137 | - } |
|
138 | - return $this; |
|
139 | - } |
|
135 | + $this->addError('match', $msg); |
|
136 | + } |
|
137 | + } |
|
138 | + return $this; |
|
139 | + } |
|
140 | 140 | |
141 | - public function unique(array $data, $msg = null) |
|
142 | - { |
|
143 | - $value = $this->value($this->input); |
|
141 | + public function unique(array $data, $msg = null) |
|
142 | + { |
|
143 | + $value = $this->value($this->input); |
|
144 | 144 | |
145 | - $table = null; |
|
146 | - $column = null; |
|
145 | + $table = null; |
|
146 | + $column = null; |
|
147 | 147 | |
148 | - $id = null; |
|
149 | - $userId = null; |
|
148 | + $id = null; |
|
149 | + $userId = null; |
|
150 | 150 | |
151 | - if (count($data) == 2) { |
|
151 | + if (count($data) == 2) { |
|
152 | 152 | |
153 | - list($table, $column) = $data; |
|
153 | + list($table, $column) = $data; |
|
154 | 154 | |
155 | - } elseif (count($data) == 4) { |
|
155 | + } elseif (count($data) == 4) { |
|
156 | 156 | |
157 | - list($table, $column, $id, $userId) = $data; |
|
158 | - } |
|
157 | + list($table, $column, $id, $userId) = $data; |
|
158 | + } |
|
159 | 159 | |
160 | - $sql = $userId ? $column . ' = ? AND ' . $id . ' != ? ' : $column . ' = ?'; |
|
160 | + $sql = $userId ? $column . ' = ? AND ' . $id . ' != ? ' : $column . ' = ?'; |
|
161 | 161 | |
162 | - $valueSql = $userId ? [$value, $userId] : $value; |
|
162 | + $valueSql = $userId ? [$value, $userId] : $value; |
|
163 | 163 | |
164 | - $result = $this->app->db->select($column)->from($table)->where($sql, $valueSql)->fetch(); |
|
164 | + $result = $this->app->db->select($column)->from($table)->where($sql, $valueSql)->fetch(); |
|
165 | 165 | |
166 | - if ($result) { |
|
166 | + if ($result) { |
|
167 | 167 | |
168 | - $msg = $msg ?: sprintf('%s is already exist', ucfirst($this->input)); |
|
168 | + $msg = $msg ?: sprintf('%s is already exist', ucfirst($this->input)); |
|
169 | 169 | |
170 | - $this->addError($this->input, $msg); |
|
171 | - } |
|
172 | - return $this; |
|
173 | - } |
|
170 | + $this->addError($this->input, $msg); |
|
171 | + } |
|
172 | + return $this; |
|
173 | + } |
|
174 | 174 | |
175 | - public function message($msg = null) |
|
176 | - { |
|
177 | - $this->errors[] = $msg; |
|
175 | + public function message($msg = null) |
|
176 | + { |
|
177 | + $this->errors[] = $msg; |
|
178 | 178 | |
179 | - return $this; |
|
180 | - } |
|
179 | + return $this; |
|
180 | + } |
|
181 | 181 | |
182 | - public function passes() |
|
183 | - { |
|
184 | - return empty($this->errors); |
|
185 | - } |
|
182 | + public function passes() |
|
183 | + { |
|
184 | + return empty($this->errors); |
|
185 | + } |
|
186 | 186 | |
187 | - public function fails() |
|
188 | - { |
|
189 | - return ! empty($this->errors); |
|
190 | - } |
|
187 | + public function fails() |
|
188 | + { |
|
189 | + return ! empty($this->errors); |
|
190 | + } |
|
191 | 191 | |
192 | - public function getMsgs() |
|
193 | - { |
|
194 | - return $this->errors; |
|
195 | - } |
|
192 | + public function getMsgs() |
|
193 | + { |
|
194 | + return $this->errors; |
|
195 | + } |
|
196 | 196 | |
197 | - private function value($input) |
|
198 | - { |
|
199 | - return $this->app->request->post($input); |
|
200 | - } |
|
197 | + private function value($input) |
|
198 | + { |
|
199 | + return $this->app->request->post($input); |
|
200 | + } |
|
201 | 201 | |
202 | - public function addError($input, $msg) |
|
203 | - { |
|
204 | - if (! $this->checkError($input)) { |
|
202 | + public function addError($input, $msg) |
|
203 | + { |
|
204 | + if (! $this->checkError($input)) { |
|
205 | 205 | |
206 | - $this->errors[$input] = $msg; |
|
207 | - } |
|
208 | - } |
|
206 | + $this->errors[$input] = $msg; |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - private function checkError($input) |
|
211 | - { |
|
212 | - return array_key_exists($input, $this->errors); |
|
213 | - } |
|
210 | + private function checkError($input) |
|
211 | + { |
|
212 | + return array_key_exists($input, $this->errors); |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | \ No newline at end of file |
@@ -24,7 +24,9 @@ discard block |
||
24 | 24 | |
25 | 25 | public function require($input = null, $msg = null) |
26 | 26 | { |
27 | - if (! $this->input) $this->input = $input; |
|
27 | + if (! $this->input) { |
|
28 | + $this->input = $input; |
|
29 | + } |
|
28 | 30 | |
29 | 31 | $value = $this->value($this->input); |
30 | 32 | |
@@ -39,7 +41,9 @@ discard block |
||
39 | 41 | |
40 | 42 | public function email($input = null, $msg = null) |
41 | 43 | { |
42 | - if (! $this->input) $this->input = $input; |
|
44 | + if (! $this->input) { |
|
45 | + $this->input = $input; |
|
46 | + } |
|
43 | 47 | |
44 | 48 | $value = $this->value($this->input); |
45 | 49 | |
@@ -54,7 +58,9 @@ discard block |
||
54 | 58 | |
55 | 59 | public function number($input = null, $msg = null) |
56 | 60 | { |
57 | - if (! $this->input) $this->input = $input; |
|
61 | + if (! $this->input) { |
|
62 | + $this->input = $input; |
|
63 | + } |
|
58 | 64 | |
59 | 65 | $value = $this->value($this->input); |
60 | 66 | |
@@ -72,7 +78,9 @@ discard block |
||
72 | 78 | |
73 | 79 | public function text($input = null, $msg = null) |
74 | 80 | { |
75 | - if (! $this->input) $this->input = $input; |
|
81 | + if (! $this->input) { |
|
82 | + $this->input = $input; |
|
83 | + } |
|
76 | 84 | |
77 | 85 | $value = $this->value($this->input); |
78 | 86 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use System\Application; |
4 | 4 | |
5 | -if (! function_exists('pre')) { |
|
5 | +if (!function_exists('pre')) { |
|
6 | 6 | function pre($var) { |
7 | 7 | echo '<pre>'; |
8 | 8 | print_r($var); |
@@ -10,28 +10,28 @@ discard block |
||
10 | 10 | } |
11 | 11 | } |
12 | 12 | |
13 | -if (! function_exists('array_get')) { |
|
13 | +if (!function_exists('array_get')) { |
|
14 | 14 | function array_get($array, $key, $default = null) |
15 | 15 | { |
16 | 16 | return $array[$key] ?: $default; |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if (! function_exists('app')) { |
|
20 | +if (!function_exists('app')) { |
|
21 | 21 | function app() |
22 | 22 | { |
23 | 23 | return Application::getInstance(); |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | -if (! function_exists('_e')) { |
|
27 | +if (!function_exists('_e')) { |
|
28 | 28 | function _e($value) |
29 | 29 | { |
30 | 30 | return htmlspecialchars($value); |
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | -if (! function_exists('getLastIndex')) { |
|
34 | +if (!function_exists('getLastIndex')) { |
|
35 | 35 | function getLastIndex($index) |
36 | 36 | { |
37 | 37 | $array = explode('\\', $index); |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | -if (! function_exists('url')) { |
|
42 | +if (!function_exists('url')) { |
|
43 | 43 | function url($path) { |
44 | 44 | $app = Application::getInstance(); |
45 | 45 | return $app->url->link($path); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -if (! function_exists('assets')) { |
|
49 | +if (!function_exists('assets')) { |
|
50 | 50 | function assets($path) |
51 | 51 | { |
52 | 52 | $app = Application::getInstance(); |
@@ -54,24 +54,24 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -if (! function_exists('remove_space')) { |
|
57 | +if (!function_exists('remove_space')) { |
|
58 | 58 | function remove_space($str) { |
59 | 59 | return str_replace(' ', '-', $str); |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -if (! function_exists('remove_dash')) { |
|
63 | +if (!function_exists('remove_dash')) { |
|
64 | 64 | function remove_dash($str) { |
65 | 65 | return str_replace('-', ' ', $str); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if (! function_exists('clean_name_url')) { |
|
69 | +if (!function_exists('clean_name_url')) { |
|
70 | 70 | function clean_name_url($class = null) { |
71 | 71 | |
72 | 72 | $app = Application::getInstance(); |
73 | 73 | |
74 | - if (! $class) { |
|
74 | + if (!$class) { |
|
75 | 75 | |
76 | 76 | $class = debug_backtrace()[1]['class']; |
77 | 77 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | $class = strtolower($class); |
85 | 85 | |
86 | - $class = '/' . $class . '/'; |
|
86 | + $class = '/' . $class . '/'; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $url = $app->request->url(); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | -if (! function_exists('text_char_limit')) { |
|
99 | +if (!function_exists('text_char_limit')) { |
|
100 | 100 | function text_char_limit($text, $limit) { |
101 | 101 | if (strlen($text) > $limit) { |
102 | 102 | return substr($text, 0, $limit) . '...'; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -if (! function_exists('array_equal')) { |
|
107 | +if (!function_exists('array_equal')) { |
|
108 | 108 | function array_equal($a, $b) { |
109 | 109 | return ( |
110 | 110 | is_array($a) |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | -if (! function_exists('redirect_after')) { |
|
118 | +if (!function_exists('redirect_after')) { |
|
119 | 119 | function redirect_after($num) { |
120 | 120 | $app = Application::getInstance(); |
121 | 121 | $app->url->redirectTo('/', $num); |
@@ -3,121 +3,121 @@ |
||
3 | 3 | use System\Application; |
4 | 4 | |
5 | 5 | if (! function_exists('pre')) { |
6 | - function pre($var) { |
|
7 | - echo '<pre>'; |
|
8 | - print_r($var); |
|
9 | - echo '</pre>'; |
|
10 | - } |
|
6 | + function pre($var) { |
|
7 | + echo '<pre>'; |
|
8 | + print_r($var); |
|
9 | + echo '</pre>'; |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | if (! function_exists('array_get')) { |
14 | - function array_get($array, $key, $default = null) |
|
15 | - { |
|
16 | - return $array[$key] ?: $default; |
|
17 | - } |
|
14 | + function array_get($array, $key, $default = null) |
|
15 | + { |
|
16 | + return $array[$key] ?: $default; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | if (! function_exists('app')) { |
21 | - function app() |
|
22 | - { |
|
23 | - return Application::getInstance(); |
|
24 | - } |
|
21 | + function app() |
|
22 | + { |
|
23 | + return Application::getInstance(); |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | if (! function_exists('_e')) { |
28 | - function _e($value) |
|
29 | - { |
|
30 | - return htmlspecialchars($value); |
|
31 | - } |
|
28 | + function _e($value) |
|
29 | + { |
|
30 | + return htmlspecialchars($value); |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | if (! function_exists('getLastIndex')) { |
35 | - function getLastIndex($index) |
|
36 | - { |
|
37 | - $array = explode('\\', $index); |
|
38 | - return end($array); |
|
39 | - } |
|
35 | + function getLastIndex($index) |
|
36 | + { |
|
37 | + $array = explode('\\', $index); |
|
38 | + return end($array); |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | if (! function_exists('url')) { |
43 | - function url($path) { |
|
44 | - $app = Application::getInstance(); |
|
45 | - return $app->url->link($path); |
|
46 | - } |
|
43 | + function url($path) { |
|
44 | + $app = Application::getInstance(); |
|
45 | + return $app->url->link($path); |
|
46 | + } |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | if (! function_exists('assets')) { |
50 | - function assets($path) |
|
51 | - { |
|
52 | - $app = Application::getInstance(); |
|
53 | - return $app->url->link('public' . DS . $path); |
|
54 | - } |
|
50 | + function assets($path) |
|
51 | + { |
|
52 | + $app = Application::getInstance(); |
|
53 | + return $app->url->link('public' . DS . $path); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | if (! function_exists('remove_space')) { |
58 | - function remove_space($str) { |
|
59 | - return str_replace(' ', '-', $str); |
|
60 | - } |
|
58 | + function remove_space($str) { |
|
59 | + return str_replace(' ', '-', $str); |
|
60 | + } |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | if (! function_exists('remove_dash')) { |
64 | - function remove_dash($str) { |
|
65 | - return str_replace('-', ' ', $str); |
|
66 | - } |
|
64 | + function remove_dash($str) { |
|
65 | + return str_replace('-', ' ', $str); |
|
66 | + } |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | if (! function_exists('clean_name_url')) { |
70 | - function clean_name_url($class = null) { |
|
70 | + function clean_name_url($class = null) { |
|
71 | 71 | |
72 | - $app = Application::getInstance(); |
|
72 | + $app = Application::getInstance(); |
|
73 | 73 | |
74 | - if (! $class) { |
|
74 | + if (! $class) { |
|
75 | 75 | |
76 | - $class = debug_backtrace()[1]['class']; |
|
76 | + $class = debug_backtrace()[1]['class']; |
|
77 | 77 | |
78 | - $clases = explode('\\', $class); |
|
78 | + $clases = explode('\\', $class); |
|
79 | 79 | |
80 | - $class = end($clases); |
|
80 | + $class = end($clases); |
|
81 | 81 | |
82 | - $class = str_replace('Controller', '', $class); |
|
82 | + $class = str_replace('Controller', '', $class); |
|
83 | 83 | |
84 | - $class = strtolower($class); |
|
84 | + $class = strtolower($class); |
|
85 | 85 | |
86 | - $class = '/' . $class . '/'; |
|
87 | - } |
|
86 | + $class = '/' . $class . '/'; |
|
87 | + } |
|
88 | 88 | |
89 | - $url = $app->request->url(); |
|
89 | + $url = $app->request->url(); |
|
90 | 90 | |
91 | - $name = str_replace($class, '', $url); |
|
91 | + $name = str_replace($class, '', $url); |
|
92 | 92 | |
93 | - $name = remove_dash($name); |
|
93 | + $name = remove_dash($name); |
|
94 | 94 | |
95 | - return $name; |
|
96 | - } |
|
95 | + return $name; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | if (! function_exists('text_char_limit')) { |
100 | - function text_char_limit($text, $limit) { |
|
101 | - if (strlen($text) > $limit) { |
|
102 | - return substr($text, 0, $limit) . '...'; |
|
103 | - } |
|
104 | - } |
|
100 | + function text_char_limit($text, $limit) { |
|
101 | + if (strlen($text) > $limit) { |
|
102 | + return substr($text, 0, $limit) . '...'; |
|
103 | + } |
|
104 | + } |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | if (! function_exists('array_equal')) { |
108 | - function array_equal($a, $b) { |
|
109 | - return ( |
|
110 | - is_array($a) |
|
111 | - && is_array($b) |
|
112 | - && count($a) == count($b) |
|
113 | - && array_diff($a, $b) === array_diff($b, $a) |
|
114 | - ); |
|
115 | - } |
|
108 | + function array_equal($a, $b) { |
|
109 | + return ( |
|
110 | + is_array($a) |
|
111 | + && is_array($b) |
|
112 | + && count($a) == count($b) |
|
113 | + && array_diff($a, $b) === array_diff($b, $a) |
|
114 | + ); |
|
115 | + } |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | if (! function_exists('redirect_after')) { |
119 | - function redirect_after($num) { |
|
120 | - $app = Application::getInstance(); |
|
121 | - $app->url->redirectTo('/', $num); |
|
122 | - } |
|
119 | + function redirect_after($num) { |
|
120 | + $app = Application::getInstance(); |
|
121 | + $app->url->redirectTo('/', $num); |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | \ No newline at end of file |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | $userGroup->pages = []; |
20 | 20 | |
21 | - foreach($userGroupInfos as $userGroupInfo) { |
|
21 | + foreach ($userGroupInfos as $userGroupInfo) { |
|
22 | 22 | |
23 | 23 | $userGroup->pages[] = $userGroupInfo->page; |
24 | 24 | } |
@@ -6,24 +6,24 @@ |
||
6 | 6 | |
7 | 7 | class UsersGroupsModel extends Model |
8 | 8 | { |
9 | - protected $table = 'users_groups'; |
|
9 | + protected $table = 'users_groups'; |
|
10 | 10 | |
11 | - public function get($id) |
|
12 | - { |
|
13 | - $userGroup = parent::get($id); |
|
11 | + public function get($id) |
|
12 | + { |
|
13 | + $userGroup = parent::get($id); |
|
14 | 14 | |
15 | - if ($userGroup) { |
|
15 | + if ($userGroup) { |
|
16 | 16 | |
17 | - $userGroupInfos = $this->hasMany('UsersGroupPermissionsModel', $id); |
|
17 | + $userGroupInfos = $this->hasMany('UsersGroupPermissionsModel', $id); |
|
18 | 18 | |
19 | - $userGroup->pages = []; |
|
19 | + $userGroup->pages = []; |
|
20 | 20 | |
21 | - foreach($userGroupInfos as $userGroupInfo) { |
|
21 | + foreach($userGroupInfos as $userGroupInfo) { |
|
22 | 22 | |
23 | - $userGroup->pages[] = $userGroupInfo->page; |
|
24 | - } |
|
23 | + $userGroup->pages[] = $userGroupInfo->page; |
|
24 | + } |
|
25 | 25 | |
26 | - return $userGroup; |
|
27 | - } |
|
28 | - } |
|
26 | + return $userGroup; |
|
27 | + } |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function loadAll() |
14 | 14 | { |
15 | - foreach($this->all() as $setting) { |
|
15 | + foreach ($this->all() as $setting) { |
|
16 | 16 | |
17 | 17 | $this->settings[$setting->key] = $setting->value; |
18 | 18 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class SettingsModel extends Model |
8 | 8 | { |
9 | - protected $table = 'settings'; |
|
9 | + protected $table = 'settings'; |
|
10 | 10 | |
11 | - private $settings; |
|
11 | + private $settings; |
|
12 | 12 | |
13 | - public function loadAll() |
|
14 | - { |
|
15 | - foreach($this->all() as $setting) { |
|
13 | + public function loadAll() |
|
14 | + { |
|
15 | + foreach($this->all() as $setting) { |
|
16 | 16 | |
17 | - $this->settings[$setting->key] = $setting->value; |
|
18 | - } |
|
19 | - } |
|
17 | + $this->settings[$setting->key] = $setting->value; |
|
18 | + } |
|
19 | + } |
|
20 | 20 | |
21 | - public function get($key) |
|
22 | - { |
|
23 | - return array_get($this->settings, $key); |
|
24 | - } |
|
21 | + public function get($key) |
|
22 | + { |
|
23 | + return array_get($this->settings, $key); |
|
24 | + } |
|
25 | 25 | |
26 | - public function updateSettings() |
|
27 | - { |
|
26 | + public function updateSettings() |
|
27 | + { |
|
28 | 28 | |
29 | - } |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -27,7 +27,7 @@ |
||
27 | 27 | 'middleware' => ['admin'] |
28 | 28 | ]; |
29 | 29 | |
30 | -$app->route->group($adminOptions, function ($route) { |
|
30 | +$app->route->group($adminOptions, function($route) { |
|
31 | 31 | |
32 | 32 | $route->add('/', 'Home'); |
33 | 33 |
@@ -3,23 +3,23 @@ |
||
3 | 3 | $app = app(); |
4 | 4 | |
5 | 5 | $adminOptions = [ |
6 | - 'prefix' => '/admin', |
|
7 | - 'controller' => 'Admin', |
|
8 | - 'middleware' => ['admin'] |
|
6 | + 'prefix' => '/admin', |
|
7 | + 'controller' => 'Admin', |
|
8 | + 'middleware' => ['admin'] |
|
9 | 9 | ]; |
10 | 10 | |
11 | 11 | $app->route->group($adminOptions, function ($route) { |
12 | 12 | |
13 | - $route->add('/', 'Home'); |
|
13 | + $route->add('/', 'Home'); |
|
14 | 14 | |
15 | - //Login |
|
16 | - $route->add('/login', 'Login'); |
|
17 | - $route->add('/submit', 'Login@submit', 'POST'); |
|
18 | - $route->add('/logout', 'Logout'); |
|
15 | + //Login |
|
16 | + $route->add('/login', 'Login'); |
|
17 | + $route->add('/submit', 'Login@submit', 'POST'); |
|
18 | + $route->add('/logout', 'Logout'); |
|
19 | 19 | |
20 | - //Profile |
|
21 | - $route->add('/profile', 'Profile', 'GET'); |
|
20 | + //Profile |
|
21 | + $route->add('/profile', 'Profile', 'GET'); |
|
22 | 22 | |
23 | - //Settings |
|
24 | - $route->add('/settings', 'Settings'); |
|
23 | + //Settings |
|
24 | + $route->add('/settings', 'Settings'); |
|
25 | 25 | }); |
26 | 26 | \ No newline at end of file |
@@ -89,7 +89,7 @@ |
||
89 | 89 | |
90 | 90 | public function get($key) |
91 | 91 | { |
92 | - if (! $this->isSharing($key)) { |
|
92 | + if (!$this->isSharing($key)) { |
|
93 | 93 | |
94 | 94 | if ($this->isCoreAlias($key)) { |
95 | 95 |
@@ -11,123 +11,123 @@ |
||
11 | 11 | |
12 | 12 | class Application |
13 | 13 | { |
14 | - private $container = []; |
|
14 | + private $container = []; |
|
15 | 15 | |
16 | - private static $instance; |
|
16 | + private static $instance; |
|
17 | 17 | |
18 | - public function __construct(File $file) |
|
19 | - { |
|
20 | - $this->handleErrors(); |
|
18 | + public function __construct(File $file) |
|
19 | + { |
|
20 | + $this->handleErrors(); |
|
21 | 21 | |
22 | - $this->share('file', $file); |
|
22 | + $this->share('file', $file); |
|
23 | 23 | |
24 | - $this->share('config', $this->file->call($this->file->to('config', '.php'))); |
|
24 | + $this->share('config', $this->file->call($this->file->to('config', '.php'))); |
|
25 | 25 | |
26 | - $this->share('alias', $this->file->call($this->file->to('config/alias', '.php'))); |
|
26 | + $this->share('alias', $this->file->call($this->file->to('config/alias', '.php'))); |
|
27 | 27 | |
28 | - $this->loadHelpers(); |
|
29 | - } |
|
28 | + $this->loadHelpers(); |
|
29 | + } |
|
30 | 30 | |
31 | - private function handleErrors() { |
|
31 | + private function handleErrors() { |
|
32 | 32 | |
33 | - $run = new Whoops(); |
|
33 | + $run = new Whoops(); |
|
34 | 34 | |
35 | - $run->prependHandler(new PrettyPageHandler()); |
|
35 | + $run->prependHandler(new PrettyPageHandler()); |
|
36 | 36 | |
37 | - if (WhoopsMisc::isAjaxRequest()) { |
|
37 | + if (WhoopsMisc::isAjaxRequest()) { |
|
38 | 38 | |
39 | - $jsonHandler = new JsonResponseHandler(); |
|
39 | + $jsonHandler = new JsonResponseHandler(); |
|
40 | 40 | |
41 | - $jsonHandler->setJsonApi(true); |
|
41 | + $jsonHandler->setJsonApi(true); |
|
42 | 42 | |
43 | - $run->prependHandler($jsonHandler); |
|
44 | - } |
|
43 | + $run->prependHandler($jsonHandler); |
|
44 | + } |
|
45 | 45 | |
46 | - $run->register(); |
|
47 | - } |
|
46 | + $run->register(); |
|
47 | + } |
|
48 | 48 | |
49 | - public static function getInstance($file = null) |
|
50 | - { |
|
51 | - return static::$instance = is_null(static::$instance) ? new static($file) : static::$instance; |
|
52 | - } |
|
49 | + public static function getInstance($file = null) |
|
50 | + { |
|
51 | + return static::$instance = is_null(static::$instance) ? new static($file) : static::$instance; |
|
52 | + } |
|
53 | 53 | |
54 | - public function run() |
|
55 | - { |
|
56 | - $this->session->start(); |
|
54 | + public function run() |
|
55 | + { |
|
56 | + $this->session->start(); |
|
57 | 57 | |
58 | - $this->request->prepareUrl(); |
|
58 | + $this->request->prepareUrl(); |
|
59 | 59 | |
60 | - $this->file->call($this->file->to('config/constant.php')); |
|
60 | + $this->file->call($this->file->to('config/constant.php')); |
|
61 | 61 | |
62 | - foreach (glob("routes/**/*.php") as $route) { |
|
62 | + foreach (glob("routes/**/*.php") as $route) { |
|
63 | 63 | |
64 | - $this->file->call($this->file->to($route)); |
|
65 | - } |
|
64 | + $this->file->call($this->file->to($route)); |
|
65 | + } |
|
66 | 66 | |
67 | - $output = $this->route->getProperRoute(); |
|
67 | + $output = $this->route->getProperRoute(); |
|
68 | 68 | |
69 | - $this->response->setOutput($output); |
|
69 | + $this->response->setOutput($output); |
|
70 | 70 | |
71 | - $this->response->send(); |
|
72 | - } |
|
71 | + $this->response->send(); |
|
72 | + } |
|
73 | 73 | |
74 | - private function loadHelpers() |
|
75 | - { |
|
76 | - $helpers = $this->file->to('Core/helpers', '.php'); |
|
74 | + private function loadHelpers() |
|
75 | + { |
|
76 | + $helpers = $this->file->to('Core/helpers', '.php'); |
|
77 | 77 | |
78 | - $this->file->call($helpers); |
|
79 | - } |
|
78 | + $this->file->call($helpers); |
|
79 | + } |
|
80 | 80 | |
81 | - public function coreClasses() |
|
82 | - { |
|
83 | - return $this->alias['classes']; |
|
84 | - } |
|
81 | + public function coreClasses() |
|
82 | + { |
|
83 | + return $this->alias['classes']; |
|
84 | + } |
|
85 | 85 | |
86 | - public function share($key, $value) |
|
87 | - { |
|
88 | - if ($value instanceof Closure) { |
|
86 | + public function share($key, $value) |
|
87 | + { |
|
88 | + if ($value instanceof Closure) { |
|
89 | 89 | |
90 | - $value = call_user_func($value, $this); |
|
91 | - } |
|
90 | + $value = call_user_func($value, $this); |
|
91 | + } |
|
92 | 92 | |
93 | - $this->container[$key] = $value; |
|
94 | - } |
|
93 | + $this->container[$key] = $value; |
|
94 | + } |
|
95 | 95 | |
96 | - public function get($key) |
|
97 | - { |
|
98 | - if (! $this->isSharing($key)) { |
|
96 | + public function get($key) |
|
97 | + { |
|
98 | + if (! $this->isSharing($key)) { |
|
99 | 99 | |
100 | - if ($this->isCoreAlias($key)) { |
|
100 | + if ($this->isCoreAlias($key)) { |
|
101 | 101 | |
102 | - $this->share($key, $this->createObject($key)); |
|
102 | + $this->share($key, $this->createObject($key)); |
|
103 | 103 | |
104 | - } else { |
|
104 | + } else { |
|
105 | 105 | |
106 | - throw new Exception("$key is not found"); |
|
107 | - } |
|
108 | - } |
|
109 | - return $this->container[$key]; |
|
110 | - } |
|
106 | + throw new Exception("$key is not found"); |
|
107 | + } |
|
108 | + } |
|
109 | + return $this->container[$key]; |
|
110 | + } |
|
111 | 111 | |
112 | - public function isSharing($key) |
|
113 | - { |
|
114 | - return isset($this->container[$key]); |
|
115 | - } |
|
112 | + public function isSharing($key) |
|
113 | + { |
|
114 | + return isset($this->container[$key]); |
|
115 | + } |
|
116 | 116 | |
117 | - public function isCoreAlias($key) |
|
118 | - { |
|
119 | - return isset($this->coreClasses()[$key]); |
|
120 | - } |
|
117 | + public function isCoreAlias($key) |
|
118 | + { |
|
119 | + return isset($this->coreClasses()[$key]); |
|
120 | + } |
|
121 | 121 | |
122 | - public function createObject($key) |
|
123 | - { |
|
124 | - $object = $this->coreClasses()[$key]; |
|
122 | + public function createObject($key) |
|
123 | + { |
|
124 | + $object = $this->coreClasses()[$key]; |
|
125 | 125 | |
126 | - return new $object($this); |
|
127 | - } |
|
126 | + return new $object($this); |
|
127 | + } |
|
128 | 128 | |
129 | - public function __get($key) |
|
130 | - { |
|
131 | - return $this->get($key); |
|
132 | - } |
|
129 | + public function __get($key) |
|
130 | + { |
|
131 | + return $this->get($key); |
|
132 | + } |
|
133 | 133 | } |
134 | 134 | \ No newline at end of file |
@@ -34,7 +34,7 @@ |
||
34 | 34 | |
35 | 35 | public function sendHeaders() |
36 | 36 | { |
37 | - foreach($this->headers as $header => $value) |
|
37 | + foreach ($this->headers as $header => $value) |
|
38 | 38 | { |
39 | 39 | header($header . ':' . $value); |
40 | 40 | } |
@@ -6,44 +6,44 @@ |
||
6 | 6 | |
7 | 7 | class Response |
8 | 8 | { |
9 | - private $app; |
|
10 | - |
|
11 | - private $headers = []; |
|
12 | - |
|
13 | - private $content = ''; |
|
14 | - |
|
15 | - public function __construct(Application $app) |
|
16 | - { |
|
17 | - $this->app = $app; |
|
18 | - } |
|
19 | - |
|
20 | - public function setOutput($content) |
|
21 | - { |
|
22 | - $this->content = $content; |
|
23 | - } |
|
24 | - |
|
25 | - public function setHeaders($header, $value) |
|
26 | - { |
|
27 | - $this->headers[$header] = $value; |
|
28 | - } |
|
29 | - |
|
30 | - public function sendOutput() |
|
31 | - { |
|
32 | - echo $this->content; |
|
33 | - } |
|
34 | - |
|
35 | - public function sendHeaders() |
|
36 | - { |
|
37 | - foreach($this->headers as $header => $value) |
|
38 | - { |
|
39 | - header($header . ':' . $value); |
|
40 | - } |
|
41 | - } |
|
42 | - |
|
43 | - public function send() |
|
44 | - { |
|
45 | - $this->sendHeaders(); |
|
46 | - |
|
47 | - $this->sendOutput(); |
|
48 | - } |
|
9 | + private $app; |
|
10 | + |
|
11 | + private $headers = []; |
|
12 | + |
|
13 | + private $content = ''; |
|
14 | + |
|
15 | + public function __construct(Application $app) |
|
16 | + { |
|
17 | + $this->app = $app; |
|
18 | + } |
|
19 | + |
|
20 | + public function setOutput($content) |
|
21 | + { |
|
22 | + $this->content = $content; |
|
23 | + } |
|
24 | + |
|
25 | + public function setHeaders($header, $value) |
|
26 | + { |
|
27 | + $this->headers[$header] = $value; |
|
28 | + } |
|
29 | + |
|
30 | + public function sendOutput() |
|
31 | + { |
|
32 | + echo $this->content; |
|
33 | + } |
|
34 | + |
|
35 | + public function sendHeaders() |
|
36 | + { |
|
37 | + foreach($this->headers as $header => $value) |
|
38 | + { |
|
39 | + header($header . ':' . $value); |
|
40 | + } |
|
41 | + } |
|
42 | + |
|
43 | + public function send() |
|
44 | + { |
|
45 | + $this->sendHeaders(); |
|
46 | + |
|
47 | + $this->sendOutput(); |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -25,7 +25,7 @@ |
||
25 | 25 | { |
26 | 26 | $page = $this->app->request->get('page'); |
27 | 27 | |
28 | - if (! is_numeric($page) || $page < 1) { |
|
28 | + if (!is_numeric($page) || $page < 1) { |
|
29 | 29 | $page = 1; |
30 | 30 | } |
31 | 31 |
@@ -4,87 +4,87 @@ |
||
4 | 4 | |
5 | 5 | class Pagination |
6 | 6 | { |
7 | - private $app; |
|
7 | + private $app; |
|
8 | 8 | |
9 | - private $totalItems; |
|
9 | + private $totalItems; |
|
10 | 10 | |
11 | - private $itemsPerPage = 10; |
|
11 | + private $itemsPerPage = 10; |
|
12 | 12 | |
13 | - private $lastPage; |
|
13 | + private $lastPage; |
|
14 | 14 | |
15 | - private $page = 1; |
|
15 | + private $page = 1; |
|
16 | 16 | |
17 | - public function __construct(Application $app) |
|
18 | - { |
|
19 | - $this->app = $app; |
|
17 | + public function __construct(Application $app) |
|
18 | + { |
|
19 | + $this->app = $app; |
|
20 | 20 | |
21 | - $this->setCurrentPage(); |
|
22 | - } |
|
21 | + $this->setCurrentPage(); |
|
22 | + } |
|
23 | 23 | |
24 | - private function setCurrentPage() |
|
25 | - { |
|
26 | - $page = $this->app->request->get('page'); |
|
24 | + private function setCurrentPage() |
|
25 | + { |
|
26 | + $page = $this->app->request->get('page'); |
|
27 | 27 | |
28 | - if (! is_numeric($page) || $page < 1) { |
|
29 | - $page = 1; |
|
30 | - } |
|
28 | + if (! is_numeric($page) || $page < 1) { |
|
29 | + $page = 1; |
|
30 | + } |
|
31 | 31 | |
32 | - $this->page = $page; |
|
33 | - } |
|
32 | + $this->page = $page; |
|
33 | + } |
|
34 | 34 | |
35 | - public function page() |
|
36 | - { |
|
37 | - return $this->page; |
|
38 | - } |
|
35 | + public function page() |
|
36 | + { |
|
37 | + return $this->page; |
|
38 | + } |
|
39 | 39 | |
40 | - public function itemsPerPage() |
|
41 | - { |
|
42 | - return $this->itemsPerPage; |
|
43 | - } |
|
40 | + public function itemsPerPage() |
|
41 | + { |
|
42 | + return $this->itemsPerPage; |
|
43 | + } |
|
44 | 44 | |
45 | - public function totalItems() |
|
46 | - { |
|
47 | - return $this->totalItems; |
|
48 | - } |
|
45 | + public function totalItems() |
|
46 | + { |
|
47 | + return $this->totalItems; |
|
48 | + } |
|
49 | 49 | |
50 | - public function last() |
|
51 | - { |
|
52 | - return $this->lastPage; |
|
53 | - } |
|
50 | + public function last() |
|
51 | + { |
|
52 | + return $this->lastPage; |
|
53 | + } |
|
54 | 54 | |
55 | - public function next() |
|
56 | - { |
|
57 | - return $this->page + 1; |
|
58 | - } |
|
55 | + public function next() |
|
56 | + { |
|
57 | + return $this->page + 1; |
|
58 | + } |
|
59 | 59 | |
60 | - public function prev() |
|
61 | - { |
|
62 | - return $this->page - 1; |
|
63 | - } |
|
60 | + public function prev() |
|
61 | + { |
|
62 | + return $this->page - 1; |
|
63 | + } |
|
64 | 64 | |
65 | - public function setTotalItems($totalItems) |
|
66 | - { |
|
67 | - $this->totalItems = $totalItems; |
|
65 | + public function setTotalItems($totalItems) |
|
66 | + { |
|
67 | + $this->totalItems = $totalItems; |
|
68 | 68 | |
69 | - return $this; |
|
70 | - } |
|
69 | + return $this; |
|
70 | + } |
|
71 | 71 | |
72 | - public function setItemsPerPage($itemsPerPage) |
|
73 | - { |
|
74 | - $this->itemsPerPage = $itemsPerPage; |
|
72 | + public function setItemsPerPage($itemsPerPage) |
|
73 | + { |
|
74 | + $this->itemsPerPage = $itemsPerPage; |
|
75 | 75 | |
76 | - return $this; |
|
77 | - } |
|
76 | + return $this; |
|
77 | + } |
|
78 | 78 | |
79 | - public function paginate() |
|
80 | - { |
|
81 | - $this->setLastPage(); |
|
79 | + public function paginate() |
|
80 | + { |
|
81 | + $this->setLastPage(); |
|
82 | 82 | |
83 | - return $this; |
|
84 | - } |
|
83 | + return $this; |
|
84 | + } |
|
85 | 85 | |
86 | - private function setLastPage() |
|
87 | - { |
|
88 | - $this->lastPage = ceil($this->totalItems / $this->itemsPerPage); |
|
89 | - } |
|
86 | + private function setLastPage() |
|
87 | + { |
|
88 | + $this->lastPage = ceil($this->totalItems / $this->itemsPerPage); |
|
89 | + } |
|
90 | 90 | } |
91 | 91 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public function handle(Application $app, $next) |
11 | 11 | { |
12 | 12 | |
13 | - if (! $this->session->has('error') || $this->session->get('error') != true) { |
|
13 | + if (!$this->session->has('error') || $this->session->get('error') != true) { |
|
14 | 14 | |
15 | 15 | $this->url->redirectTo('/'); |
16 | 16 |
@@ -7,16 +7,16 @@ |
||
7 | 7 | |
8 | 8 | class RedirectMiddleware implements Middleware |
9 | 9 | { |
10 | - public function handle(Application $app, $next) |
|
11 | - { |
|
10 | + public function handle(Application $app, $next) |
|
11 | + { |
|
12 | 12 | |
13 | - if (! $this->session->has('error') || $this->session->get('error') != true) { |
|
13 | + if (! $this->session->has('error') || $this->session->get('error') != true) { |
|
14 | 14 | |
15 | - $this->url->redirectTo('/'); |
|
15 | + $this->url->redirectTo('/'); |
|
16 | 16 | |
17 | - } else { |
|
17 | + } else { |
|
18 | 18 | |
19 | - $this->session->remove('error'); |
|
20 | - } |
|
21 | - } |
|
19 | + $this->session->remove('error'); |
|
20 | + } |
|
21 | + } |
|
22 | 22 | } |
23 | 23 | \ No newline at end of file |