@@ -48,7 +48,9 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | $str = substr($str, 0, -1); |
51 | - if (!file_put_contents($envFile, $str)) return false; |
|
51 | + if (!file_put_contents($envFile, $str)) { |
|
52 | + return false; |
|
53 | + } |
|
52 | 54 | return true; |
53 | 55 | } |
54 | 56 | } |
@@ -251,7 +253,7 @@ discard block |
||
251 | 253 | $settings = file_get_contents(storage_path('.cbconfig')); |
252 | 254 | $settings = decrypt($settings); |
253 | 255 | $settings = unserialize($settings); |
254 | - }else{ |
|
256 | + } else{ |
|
255 | 257 | $settings = []; |
256 | 258 | } |
257 | 259 | |
@@ -276,14 +278,14 @@ discard block |
||
276 | 278 | $settings = file_get_contents(storage_path('.cbconfig')); |
277 | 279 | $settings = decrypt($settings); |
278 | 280 | $settings = unserialize($settings); |
279 | - }else{ |
|
281 | + } else{ |
|
280 | 282 | $settings = []; |
281 | 283 | } |
282 | 284 | |
283 | 285 | if(isset($settings[$key])) { |
284 | 286 | \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]); |
285 | 287 | return $settings[$key]?:$default; |
286 | - }else{ |
|
288 | + } else{ |
|
287 | 289 | return $default; |
288 | 290 | } |
289 | 291 | } |
@@ -369,7 +371,7 @@ discard block |
||
369 | 371 | $url = request($name); |
370 | 372 | if(filter_var($url, FILTER_VALIDATE_URL)) { |
371 | 373 | return $url; |
372 | - }else{ |
|
374 | + } else{ |
|
373 | 375 | return request()->url(); |
374 | 376 | } |
375 | 377 | } |
@@ -381,14 +383,14 @@ discard block |
||
381 | 383 | $response = request($name); |
382 | 384 | if(is_string($response)) { |
383 | 385 | $response = sanitizeXSS($response); |
384 | - }elseif (is_array($response)) { |
|
386 | + } elseif (is_array($response)) { |
|
385 | 387 | array_walk_recursive($response, function(&$response) { |
386 | 388 | $response = sanitizeXSS($response); |
387 | 389 | }); |
388 | 390 | } |
389 | 391 | |
390 | 392 | return $response; |
391 | - }else{ |
|
393 | + } else{ |
|
392 | 394 | return Request::get($name); |
393 | 395 | } |
394 | 396 | } |
@@ -398,11 +400,13 @@ discard block |
||
398 | 400 | function min_var_export($input) { |
399 | 401 | if(is_array($input)) { |
400 | 402 | $buffer = []; |
401 | - foreach($input as $key => $value) |
|
402 | - $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
403 | + foreach($input as $key => $value) { |
|
404 | + $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
405 | + } |
|
403 | 406 | return "[".implode(",",$buffer)."]"; |
404 | - } else |
|
405 | - return var_export($input, true); |
|
407 | + } else { |
|
408 | + return var_export($input, true); |
|
409 | + } |
|
406 | 410 | } |
407 | 411 | } |
408 | 412 | |
@@ -415,10 +419,11 @@ discard block |
||
415 | 419 | $objects = scandir($dir); |
416 | 420 | foreach ($objects as $object) { |
417 | 421 | if ($object != "." && $object != "..") { |
418 | - if (is_dir($dir."/".$object)) |
|
419 | - rrmdir($dir."/".$object); |
|
420 | - else |
|
421 | - unlink($dir."/".$object); |
|
422 | + if (is_dir($dir."/".$object)) { |
|
423 | + rrmdir($dir."/".$object); |
|
424 | + } else { |
|
425 | + unlink($dir."/".$object); |
|
426 | + } |
|
422 | 427 | } |
423 | 428 | } |
424 | 429 | rmdir($dir); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!function_exists("miscellanousSingleton")) { |
|
3 | +if (!function_exists("miscellanousSingleton")) { |
|
4 | 4 | /** |
5 | 5 | * @return \crocodicstudio\crudbooster\helpers\MiscellanousSingleton |
6 | 6 | */ |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | } |
10 | 10 | } |
11 | 11 | |
12 | -if(!function_exists("makeReferalUrl")) { |
|
12 | +if (!function_exists("makeReferalUrl")) { |
|
13 | 13 | function makeReferalUrl($name = null) { |
14 | 14 | $ref = []; |
15 | 15 | $ref['url'] = request()->fullUrl(); |
16 | 16 | $ref['name'] = $name; |
17 | 17 | $md5Hash = md5(serialize($ref)); |
18 | 18 | |
19 | - if($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) { |
|
19 | + if ($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) { |
|
20 | 20 | return $exist['id']; |
21 | 21 | } |
22 | 22 | |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -if(!function_exists("getReferalUrl")) { |
|
31 | +if (!function_exists("getReferalUrl")) { |
|
32 | 32 | function getReferalUrl($key = null) { |
33 | - if(verifyReferalUrl()) { |
|
33 | + if (verifyReferalUrl()) { |
|
34 | 34 | $md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref")); |
35 | 35 | $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash); |
36 | - if($key) { |
|
36 | + if ($key) { |
|
37 | 37 | return @$ref[$key]; |
38 | 38 | } else { |
39 | 39 | return $ref; |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | -if(!function_exists("verifyReferalUrl")) { |
|
46 | +if (!function_exists("verifyReferalUrl")) { |
|
47 | 47 | function verifyReferalUrl() |
48 | 48 | { |
49 | - if(request("ref")) { |
|
50 | - if($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) { |
|
49 | + if (request("ref")) { |
|
50 | + if ($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) { |
|
51 | 51 | $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash); |
52 | - if(filter_var($ref['url'], FILTER_VALIDATE_URL)) { |
|
52 | + if (filter_var($ref['url'], FILTER_VALIDATE_URL)) { |
|
53 | 53 | return true; |
54 | 54 | } |
55 | 55 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | -if(!function_exists("putHtaccess")) { |
|
61 | +if (!function_exists("putHtaccess")) { |
|
62 | 62 | function putHtaccess($stringToPut) |
63 | 63 | { |
64 | 64 | file_put_contents(base_path(".htaccess"), "\n".$stringToPut, FILE_APPEND); |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -if(!function_exists("checkHtaccess")) { |
|
69 | +if (!function_exists("checkHtaccess")) { |
|
70 | 70 | function checkHtaccess($stringToCheck) |
71 | 71 | { |
72 | - if(file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) { |
|
72 | + if (file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) { |
|
73 | 73 | $htaccess = file_get_contents(base_path(".htaccess")); |
74 | - $htaccess2= file_get_contents(public_path(".htaccess")); |
|
75 | - if(\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) { |
|
74 | + $htaccess2 = file_get_contents(public_path(".htaccess")); |
|
75 | + if (\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) { |
|
76 | 76 | return true; |
77 | 77 | } |
78 | 78 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | -if(!function_exists("setEnvironmentValue")) { |
|
84 | +if (!function_exists("setEnvironmentValue")) { |
|
85 | 85 | function setEnvironmentValue(array $values) |
86 | 86 | { |
87 | 87 | $envFile = app()->environmentFilePath(); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | -if(!function_exists("cbLang")) { |
|
115 | +if (!function_exists("cbLang")) { |
|
116 | 116 | /** |
117 | 117 | * @param string $key |
118 | 118 | * @param array $replace |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | -if(!function_exists('rglob')) { |
|
127 | +if (!function_exists('rglob')) { |
|
128 | 128 | function rglob($pattern, $flags = 0) { |
129 | 129 | $files = glob($pattern, $flags); |
130 | - foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |
|
130 | + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
|
131 | 131 | $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags)); |
132 | 132 | } |
133 | 133 | return $files; |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | -if(!function_exists('convertPHPToMomentFormat')) { |
|
137 | +if (!function_exists('convertPHPToMomentFormat')) { |
|
138 | 138 | function convertPHPToMomentFormat($format) |
139 | 139 | { |
140 | 140 | $replacements = [ |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | -if(!function_exists('slug')) { |
|
184 | +if (!function_exists('slug')) { |
|
185 | 185 | function slug($string, $separator = '-') { |
186 | 186 | return \Illuminate\Support\Str::slug($string, $separator); |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | -if(!function_exists('columnSingleton')) { |
|
190 | +if (!function_exists('columnSingleton')) { |
|
191 | 191 | /** |
192 | 192 | * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton |
193 | 193 | */ |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | -if(!function_exists('cbHook')) |
|
199 | +if (!function_exists('cbHook')) |
|
200 | 200 | { |
201 | 201 | /** |
202 | 202 | * @return crocodicstudio\crudbooster\hooks\CBHook |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | -if(!function_exists('getTypeHook')) |
|
211 | +if (!function_exists('getTypeHook')) |
|
212 | 212 | { |
213 | 213 | /** |
214 | 214 | * @param string $type |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | -if(!function_exists('getPrimaryKey')) |
|
224 | +if (!function_exists('getPrimaryKey')) |
|
225 | 225 | { |
226 | 226 | function getPrimaryKey($table_name) |
227 | 227 | { |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | -if(!function_exists('cb')) |
|
232 | +if (!function_exists('cb')) |
|
233 | 233 | { |
234 | 234 | function cb() |
235 | 235 | { |
@@ -237,25 +237,25 @@ discard block |
||
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | -if(!function_exists('cbAsset')) { |
|
240 | +if (!function_exists('cbAsset')) { |
|
241 | 241 | function cbAsset($path, $secure = null) { |
242 | 242 | return asset("cb_asset/".$path, $secure); |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | -if(!function_exists("cbConfig")) { |
|
246 | +if (!function_exists("cbConfig")) { |
|
247 | 247 | function cbConfig($name, $default = null) { |
248 | 248 | return config("crudbooster.".$name, $default); |
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | -if(!function_exists("strRandom")) { |
|
252 | +if (!function_exists("strRandom")) { |
|
253 | 253 | function strRandom($length = 5) { |
254 | 254 | return \Illuminate\Support\Str::random($length); |
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | -if(!function_exists('module')) { |
|
258 | +if (!function_exists('module')) { |
|
259 | 259 | function module() |
260 | 260 | { |
261 | 261 | $module = new \crocodicstudio\crudbooster\helpers\Module(); |
@@ -263,21 +263,21 @@ discard block |
||
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | -if(!function_exists('getAdminLoginURL')) { |
|
266 | +if (!function_exists('getAdminLoginURL')) { |
|
267 | 267 | function getAdminLoginURL() |
268 | 268 | { |
269 | 269 | return cb()->getAdminUrl("login"); |
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
273 | -if(!function_exists('dummyPhoto')) { |
|
273 | +if (!function_exists('dummyPhoto')) { |
|
274 | 274 | function dummyPhoto() |
275 | 275 | { |
276 | 276 | return cbConfig("DUMMY_PHOTO"); |
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
280 | -if(!function_exists('extract_unit')) { |
|
280 | +if (!function_exists('extract_unit')) { |
|
281 | 281 | /* |
282 | 282 | Credits: Bit Repository |
283 | 283 | URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html |
@@ -302,14 +302,14 @@ discard block |
||
302 | 302 | | |
303 | 303 | */ |
304 | 304 | |
305 | -if(!function_exists('putSetting')) { |
|
305 | +if (!function_exists('putSetting')) { |
|
306 | 306 | function putSetting($key, $value) |
307 | 307 | { |
308 | - if(file_exists(storage_path('.cbconfig'))) { |
|
308 | + if (file_exists(storage_path('.cbconfig'))) { |
|
309 | 309 | $settings = file_get_contents(storage_path('.cbconfig')); |
310 | 310 | $settings = decrypt($settings); |
311 | 311 | $settings = unserialize($settings); |
312 | - }else{ |
|
312 | + } else { |
|
313 | 313 | $settings = []; |
314 | 314 | } |
315 | 315 | |
@@ -323,31 +323,31 @@ discard block |
||
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | -if(!function_exists('getSetting')) { |
|
326 | +if (!function_exists('getSetting')) { |
|
327 | 327 | function getSetting($key, $default = null) |
328 | 328 | { |
329 | - if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) { |
|
329 | + if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) { |
|
330 | 330 | return $cache; |
331 | 331 | } |
332 | 332 | |
333 | - if(file_exists(storage_path('.cbconfig'))) { |
|
333 | + if (file_exists(storage_path('.cbconfig'))) { |
|
334 | 334 | $settings = file_get_contents(storage_path('.cbconfig')); |
335 | 335 | $settings = decrypt($settings); |
336 | 336 | $settings = unserialize($settings); |
337 | - }else{ |
|
337 | + } else { |
|
338 | 338 | $settings = []; |
339 | 339 | } |
340 | 340 | |
341 | - if(isset($settings[$key])) { |
|
341 | + if (isset($settings[$key])) { |
|
342 | 342 | \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]); |
343 | - return $settings[$key]?:$default; |
|
344 | - }else{ |
|
343 | + return $settings[$key] ?: $default; |
|
344 | + } else { |
|
345 | 345 | return $default; |
346 | 346 | } |
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | -if(!function_exists('timeAgo')) { |
|
350 | +if (!function_exists('timeAgo')) { |
|
351 | 351 | function timeAgo($datetime_to, $datetime_from = null, $full = false) |
352 | 352 | { |
353 | 353 | $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s'); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
381 | - if (! $full) { |
|
381 | + if (!$full) { |
|
382 | 382 | $string = array_slice($string, 0, 1); |
383 | 383 | } |
384 | 384 | |
@@ -386,22 +386,22 @@ discard block |
||
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
389 | -if(!function_exists("array_map_r")) { |
|
390 | - function array_map_r( $func, $arr ) |
|
389 | +if (!function_exists("array_map_r")) { |
|
390 | + function array_map_r($func, $arr) |
|
391 | 391 | { |
392 | 392 | $newArr = array(); |
393 | 393 | |
394 | - foreach( $arr as $key => $value ) |
|
394 | + foreach ($arr as $key => $value) |
|
395 | 395 | { |
396 | 396 | $key = $func($key); |
397 | - $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) ); |
|
397 | + $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value))); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | return $newArr; |
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | -if(!function_exists("sanitizeXSS")) |
|
404 | +if (!function_exists("sanitizeXSS")) |
|
405 | 405 | { |
406 | 406 | function sanitizeXSS($value) |
407 | 407 | { |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | -if(!function_exists("requestAll")) { |
|
416 | +if (!function_exists("requestAll")) { |
|
417 | 417 | function requestAll() { |
418 | 418 | $all = array_map_r("sanitizeXSS", request()->all()); |
419 | 419 | return $all; |
@@ -422,22 +422,22 @@ discard block |
||
422 | 422 | |
423 | 423 | |
424 | 424 | |
425 | -if(!function_exists('getURLFormat')) { |
|
425 | +if (!function_exists('getURLFormat')) { |
|
426 | 426 | function getURLFormat($name) { |
427 | 427 | $url = request($name); |
428 | - if(filter_var($url, FILTER_VALIDATE_URL)) { |
|
428 | + if (filter_var($url, FILTER_VALIDATE_URL)) { |
|
429 | 429 | return $url; |
430 | - }else{ |
|
430 | + } else { |
|
431 | 431 | return request()->url(); |
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
436 | -if(!function_exists('g')) { |
|
436 | +if (!function_exists('g')) { |
|
437 | 437 | function g($name, $safe = true) { |
438 | - if($safe == true) { |
|
438 | + if ($safe == true) { |
|
439 | 439 | $response = request($name); |
440 | - if(is_string($response)) { |
|
440 | + if (is_string($response)) { |
|
441 | 441 | $response = sanitizeXSS($response); |
442 | 442 | }elseif (is_array($response)) { |
443 | 443 | array_walk_recursive($response, function(&$response) { |
@@ -446,25 +446,25 @@ discard block |
||
446 | 446 | } |
447 | 447 | |
448 | 448 | return $response; |
449 | - }else{ |
|
449 | + } else { |
|
450 | 450 | return Request::get($name); |
451 | 451 | } |
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
455 | -if(!function_exists('min_var_export')) { |
|
455 | +if (!function_exists('min_var_export')) { |
|
456 | 456 | function min_var_export($input) { |
457 | - if(is_array($input)) { |
|
457 | + if (is_array($input)) { |
|
458 | 458 | $buffer = []; |
459 | - foreach($input as $key => $value) |
|
459 | + foreach ($input as $key => $value) |
|
460 | 460 | $buffer[] = var_export($key, true)."=>".min_var_export($value); |
461 | - return "[".implode(",",$buffer)."]"; |
|
461 | + return "[".implode(",", $buffer)."]"; |
|
462 | 462 | } else |
463 | 463 | return var_export($input, true); |
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | -if(!function_exists('rrmdir')) { |
|
467 | +if (!function_exists('rrmdir')) { |
|
468 | 468 | /* |
469 | 469 | * http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir |
470 | 470 | */ |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function optionsFromTable($table, $value_option, $display_option, $SQLCondition = null) { |
43 | 43 | |
44 | - if(strpos($table,"App\Models")!==false) { |
|
44 | + if (strpos($table, "App\Models") !== false) { |
|
45 | 45 | $table = new $table(); |
46 | 46 | $table = $table::$tableName; |
47 | 47 | } |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | |
51 | 51 | $options = []; |
52 | 52 | foreach ($data as $d) { |
53 | - $options[ $d->$value_option ] = $d->$display_option; |
|
53 | + $options[$d->$value_option] = $d->$display_option; |
|
54 | 54 | } |
55 | 55 | $data = columnSingleton()->getColumn($this->index); |
56 | 56 | /** @var $data SelectTableModel */ |
57 | - $data->setOptionsFromTable(["table"=>$table,"key_field"=>$value_option,"display_field"=>$display_option,"sql_condition"=>$SQLCondition]); |
|
57 | + $data->setOptionsFromTable(["table"=>$table, "key_field"=>$value_option, "display_field"=>$display_option, "sql_condition"=>$SQLCondition]); |
|
58 | 58 | columnSingleton()->setColumn($this->index, $data); |
59 | 59 | |
60 | 60 | $this->options($options); |
@@ -25,22 +25,22 @@ discard block |
||
25 | 25 | |
26 | 26 | public function getIndex() { |
27 | 27 | $data = []; |
28 | - return view($this->view.".index",$data); |
|
28 | + return view($this->view.".index", $data); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public function getAdd() { |
32 | 32 | $data = []; |
33 | 33 | $data['form_title'] = "Add Menu"; |
34 | 34 | $data['form_url'] = route('DeveloperMenusControllerPostAddSave'); |
35 | - $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get(); |
|
35 | + $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get(); |
|
36 | 36 | return view($this->view.".form", $data); |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function getEdit($id) { |
40 | 40 | $data = []; |
41 | 41 | $data['form_title'] = "Edit Menu"; |
42 | - $data['form_url'] = route('DeveloperMenusControllerPostEditSave',['id'=>$id]); |
|
43 | - $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get(); |
|
42 | + $data['form_url'] = route('DeveloperMenusControllerPostEditSave', ['id'=>$id]); |
|
43 | + $data['modules'] = DB::table("cb_modules")->orderBy("name", "asc")->get(); |
|
44 | 44 | $data['row'] = cb()->find("cb_menus", $id); |
45 | 45 | return view($this->view.".form", $data); |
46 | 46 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $menu['name'] = request('name'); |
54 | 54 | $menu['icon'] = request('icon'); |
55 | 55 | $menu['type'] = request('type'); |
56 | - if(request('type') == 'module') { |
|
56 | + if (request('type') == 'module') { |
|
57 | 57 | $menu['cb_modules_id'] = request('cb_modules_id'); |
58 | 58 | }elseif (request('type') == 'url') { |
59 | 59 | $menu['path'] = request('url_value'); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | CacheHelper::forgetGroup("sidebar_menu"); |
67 | 67 | |
68 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been added!","success"); |
|
68 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been added!", "success"); |
|
69 | 69 | |
70 | 70 | } catch (CBValidationException $e) { |
71 | 71 | return cb()->redirectBack($e->getMessage()); |
@@ -80,18 +80,18 @@ discard block |
||
80 | 80 | $menu['name'] = request('name'); |
81 | 81 | $menu['icon'] = request('icon'); |
82 | 82 | $menu['type'] = request('type'); |
83 | - if(request('type') == 'module') { |
|
83 | + if (request('type') == 'module') { |
|
84 | 84 | $menu['cb_modules_id'] = request('cb_modules_id'); |
85 | 85 | }elseif (request('type') == 'url') { |
86 | 86 | $menu['path'] = request('url_value'); |
87 | 87 | }elseif (request('type') == 'path') { |
88 | 88 | $menu['path'] = request('path_value'); |
89 | 89 | } |
90 | - DB::table("cb_menus")->where("id",$id)->update($menu); |
|
90 | + DB::table("cb_menus")->where("id", $id)->update($menu); |
|
91 | 91 | |
92 | 92 | CacheHelper::forgetGroup("sidebar_menu"); |
93 | 93 | |
94 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been saved!","success"); |
|
94 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been saved!", "success"); |
|
95 | 95 | |
96 | 96 | } catch (CBValidationException $e) { |
97 | 97 | return cb()->redirectBack($e->getMessage()); |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | |
105 | 105 | $menus = request('menus'); |
106 | 106 | $menus = json_decode($menus, true); |
107 | - if($menus) { |
|
107 | + if ($menus) { |
|
108 | 108 | $menus = $menus[0]; |
109 | - if($menus) { |
|
110 | - foreach($menus as $i=>$menu) { |
|
109 | + if ($menus) { |
|
110 | + foreach ($menus as $i=>$menu) { |
|
111 | 111 | $id = $menu['id']; |
112 | - cb()->update("cb_menus",$id,["sort_number"=>$i,'parent_cb_menus_id'=>null]); |
|
113 | - if($menu['children'][0]) { |
|
114 | - foreach($menu['children'][0] as $ii=>$sub) { |
|
112 | + cb()->update("cb_menus", $id, ["sort_number"=>$i, 'parent_cb_menus_id'=>null]); |
|
113 | + if ($menu['children'][0]) { |
|
114 | + foreach ($menu['children'][0] as $ii=>$sub) { |
|
115 | 115 | $id = $sub['id']; |
116 | - cb()->update("cb_menus",$id,["sort_number"=>$ii,"parent_cb_menus_id"=>$menu['id']]); |
|
117 | - if($sub['children'][0]) { |
|
118 | - foreach($sub['children'][0] as $iii=>$subsub) { |
|
116 | + cb()->update("cb_menus", $id, ["sort_number"=>$ii, "parent_cb_menus_id"=>$menu['id']]); |
|
117 | + if ($sub['children'][0]) { |
|
118 | + foreach ($sub['children'][0] as $iii=>$subsub) { |
|
119 | 119 | $id = $subsub['id']; |
120 | - cb()->update("cb_menus",$id,["sort_number"=>$iii,"parent_cb_menus_id"=>$sub['id']]); |
|
120 | + cb()->update("cb_menus", $id, ["sort_number"=>$iii, "parent_cb_menus_id"=>$sub['id']]); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
@@ -128,20 +128,20 @@ discard block |
||
128 | 128 | |
129 | 129 | CacheHelper::forgetGroup("sidebar_menu"); |
130 | 130 | |
131 | - return response()->json(['api_status'=>1,'api_message'=>'success']); |
|
131 | + return response()->json(['api_status'=>1, 'api_message'=>'success']); |
|
132 | 132 | |
133 | 133 | } catch (CBValidationException $e) { |
134 | - return response()->json(['api_status'=>0,'api_message'=>$e->getMessage()]); |
|
134 | + return response()->json(['api_status'=>0, 'api_message'=>$e->getMessage()]); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | 138 | public function getDelete($id) { |
139 | - DB::table("cb_menus")->where("id",$id)->delete(); |
|
139 | + DB::table("cb_menus")->where("id", $id)->delete(); |
|
140 | 140 | DB::table("cb_role_privileges")->where("cb_menus_id", $id)->delete(); |
141 | 141 | |
142 | 142 | CacheHelper::forgetGroup("sidebar_menu"); |
143 | 143 | |
144 | - return cb()->redirectBack("The menu has been deleted!","success"); |
|
144 | + return cb()->redirectBack("The menu has been deleted!", "success"); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | } |
148 | 148 | \ No newline at end of file |
@@ -14,16 +14,16 @@ discard block |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | public function getSubModule($subModuleKey) { |
17 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
18 | - if(!verifyReferalUrl()) return cb()->redirect(module()->url(),"It looks like your url is incorrect"); |
|
17 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
18 | + if (!verifyReferalUrl()) return cb()->redirect(module()->url(), "It looks like your url is incorrect"); |
|
19 | 19 | |
20 | - if($subModule = Cache::get("subModule".$subModuleKey)) { |
|
20 | + if ($subModule = Cache::get("subModule".$subModuleKey)) { |
|
21 | 21 | $foreignKey = $subModule['foreignKey']; |
22 | 22 | $foreignValue = $subModule['foreignValue']; |
23 | 23 | |
24 | 24 | $query = $this->repository(); |
25 | 25 | $query->where($foreignKey, $foreignValue); |
26 | - $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
|
26 | + $result = $query->paginate(request("limit") ?: cbConfig("LIMIT_TABLE_DATA")); |
|
27 | 27 | $data['result'] = $result; |
28 | 28 | |
29 | 29 | $data['additionalHeaderTitle'] = $subModule['parentTitle']; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | return view("crudbooster::module.index.index", array_merge($data, $this->data)); |
34 | 34 | } |
35 | 35 | |
36 | - return cb()->redirect(module()->url(),"It looks like your url is incorrect"); |
|
36 | + return cb()->redirect(module()->url(), "It looks like your url is incorrect"); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -14,8 +14,12 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | public function getSubModule($subModuleKey) { |
17 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
18 | - if(!verifyReferalUrl()) return cb()->redirect(module()->url(),"It looks like your url is incorrect"); |
|
17 | + if(!module()->canBrowse()) { |
|
18 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
19 | + } |
|
20 | + if(!verifyReferalUrl()) { |
|
21 | + return cb()->redirect(module()->url(),"It looks like your url is incorrect"); |
|
22 | + } |
|
19 | 23 | |
20 | 24 | if($subModule = Cache::get("subModule".$subModuleKey)) { |
21 | 25 | $foreignKey = $subModule['foreignKey']; |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | |
33 | 33 | public function getIndex() |
34 | 34 | { |
35 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
35 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
36 | 36 | |
37 | 37 | $query = $this->repository(); |
38 | - $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
|
38 | + $result = $query->paginate(request("limit") ?: cbConfig("LIMIT_TABLE_DATA")); |
|
39 | 39 | $data['result'] = $result; |
40 | 40 | |
41 | 41 | return view("crudbooster::module.index.index", array_merge($data, $this->data)); |
@@ -43,17 +43,17 @@ discard block |
||
43 | 43 | |
44 | 44 | public function getAdd() |
45 | 45 | { |
46 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
46 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
47 | 47 | |
48 | 48 | $data = []; |
49 | 49 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
50 | 50 | $data['action_url'] = module()->addSaveURL(); |
51 | - return view('crudbooster::module.form.form',array_merge($data, $this->data)); |
|
51 | + return view('crudbooster::module.form.form', array_merge($data, $this->data)); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function postAddSave() |
55 | 55 | { |
56 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
56 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
57 | 57 | |
58 | 58 | try { |
59 | 59 | $this->validation(); |
@@ -61,38 +61,38 @@ discard block |
||
61 | 61 | $data = columnSingleton()->getAssignmentData(); |
62 | 62 | |
63 | 63 | //Clear data from Primary Key |
64 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
64 | + unset($data[cb()->pk($this->data['table'])]); |
|
65 | 65 | |
66 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
66 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
67 | 67 | $data['created_at'] = date('Y-m-d H:i:s'); |
68 | 68 | } |
69 | 69 | |
70 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
70 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
71 | 71 | $data['updated_at'] = date('Y-m-d H:i:s'); |
72 | 72 | } |
73 | 73 | |
74 | - if(isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
74 | + if (isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
75 | 75 | $data = call_user_func($this->data['hook_before_insert'], $data); |
76 | 76 | } |
77 | 77 | |
78 | 78 | $id = DB::table($this->data['table'])->insertGetId($data); |
79 | 79 | |
80 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
80 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
81 | 81 | call_user_func($this->data['hook_after_insert'], $id); |
82 | 82 | } |
83 | 83 | |
84 | 84 | } catch (CBValidationException $e) { |
85 | 85 | Log::debug($e); |
86 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
86 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
87 | 87 | } catch (\Exception $e) { |
88 | 88 | Log::error($e); |
89 | - return cb()->redirectBack(cbLang("something_went_wrong"),'warning'); |
|
89 | + return cb()->redirectBack(cbLang("something_went_wrong"), 'warning'); |
|
90 | 90 | } |
91 | 91 | |
92 | - if (Str::contains(request("submit"),cbLang("more"))) { |
|
92 | + if (Str::contains(request("submit"), cbLang("more"))) { |
|
93 | 93 | return cb()->redirectBack(cbLang("the_data_has_been_added"), 'success'); |
94 | 94 | } else { |
95 | - if(verifyReferalUrl()) { |
|
95 | + if (verifyReferalUrl()) { |
|
96 | 96 | return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_added"), 'success'); |
97 | 97 | } else { |
98 | 98 | return cb()->redirect(module()->url(), cbLang("the_data_has_been_added"), 'success'); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | public function getEdit($id) |
104 | 104 | { |
105 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
105 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
106 | 106 | |
107 | 107 | $data = []; |
108 | 108 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | public function postEditSave($id) |
115 | 115 | { |
116 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
116 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
117 | 117 | |
118 | 118 | try { |
119 | 119 | $this->validation(); |
@@ -121,40 +121,40 @@ discard block |
||
121 | 121 | $data = columnSingleton()->getAssignmentData(); |
122 | 122 | |
123 | 123 | // Make sure the Primary Key is not included |
124 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
124 | + unset($data[cb()->pk($this->data['table'])]); |
|
125 | 125 | |
126 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
126 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
127 | 127 | $data['updated_at'] = date('Y-m-d H:i:s'); |
128 | 128 | } |
129 | 129 | |
130 | 130 | unset($data['created_at']); |
131 | 131 | |
132 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
132 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
133 | 133 | $data = call_user_func($this->data['hook_before_update'], $id, $data); |
134 | 134 | } |
135 | 135 | |
136 | 136 | cb()->update($this->data['table'], $id, $data); |
137 | 137 | |
138 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
138 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
139 | 139 | call_user_func($this->data['hook_after_update'], $id); |
140 | 140 | } |
141 | 141 | |
142 | 142 | } catch (CBValidationException $e) { |
143 | 143 | Log::debug($e); |
144 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
144 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
145 | 145 | } catch (\Exception $e) { |
146 | 146 | Log::error($e); |
147 | - return cb()->redirectBack(cbLang("something_went_wrong"),'warning'); |
|
147 | + return cb()->redirectBack(cbLang("something_went_wrong"), 'warning'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
151 | 151 | if (Str::contains(request("submit"), cbLang("more"))) { |
152 | - return cb()->redirectBack( cbLang("the_data_has_been_updated"), 'success'); |
|
152 | + return cb()->redirectBack(cbLang("the_data_has_been_updated"), 'success'); |
|
153 | 153 | } else { |
154 | - if(verifyReferalUrl()) { |
|
155 | - return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_updated"), 'success'); |
|
154 | + if (verifyReferalUrl()) { |
|
155 | + return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_updated"), 'success'); |
|
156 | 156 | } else { |
157 | - return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success'); |
|
157 | + return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
@@ -162,15 +162,15 @@ discard block |
||
162 | 162 | |
163 | 163 | public function getDelete($id) |
164 | 164 | { |
165 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
165 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
166 | 166 | |
167 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
167 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
168 | 168 | call_user_func($this->data['hook_before_delete'], $id); |
169 | 169 | } |
170 | 170 | |
171 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
171 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
172 | 172 | |
173 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
173 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
174 | 174 | DB::table($this->data['table']) |
175 | 175 | ->where(getPrimaryKey($this->data['table']), $id) |
176 | 176 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -180,16 +180,16 @@ discard block |
||
180 | 180 | ->delete(); |
181 | 181 | } |
182 | 182 | |
183 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
183 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
184 | 184 | call_user_func($this->data['hook_after_delete'], $id); |
185 | 185 | } |
186 | 186 | |
187 | - return cb()->redirectBack( cbLang("the_data_has_been_deleted"), 'success'); |
|
187 | + return cb()->redirectBack(cbLang("the_data_has_been_deleted"), 'success'); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | public function getDetail($id) |
191 | 191 | { |
192 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
192 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
193 | 193 | |
194 | 194 | $data = []; |
195 | 195 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function __call($method, $parameters) |
210 | 210 | { |
211 | - if($method == "getData") { |
|
211 | + if ($method == "getData") { |
|
212 | 212 | $key = $parameters[0]; |
213 | - if(isset($this->data[$key])) { |
|
213 | + if (isset($this->data[$key])) { |
|
214 | 214 | return $this->data[$key]; |
215 | - }else{ |
|
215 | + } else { |
|
216 | 216 | return null; |
217 | 217 | } |
218 | - }else{ |
|
218 | + } else { |
|
219 | 219 | return null; |
220 | 220 | } |
221 | 221 | } |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | |
33 | 33 | public function getIndex() |
34 | 34 | { |
35 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
35 | + if(!module()->canBrowse()) { |
|
36 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $query = $this->repository(); |
38 | 40 | $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
@@ -43,7 +45,9 @@ discard block |
||
43 | 45 | |
44 | 46 | public function getAdd() |
45 | 47 | { |
46 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
48 | + if(!module()->canCreate()) { |
|
49 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
50 | + } |
|
47 | 51 | |
48 | 52 | $data = []; |
49 | 53 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
@@ -53,7 +57,9 @@ discard block |
||
53 | 57 | |
54 | 58 | public function postAddSave() |
55 | 59 | { |
56 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
60 | + if(!module()->canCreate()) { |
|
61 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
62 | + } |
|
57 | 63 | |
58 | 64 | try { |
59 | 65 | $this->validation(); |
@@ -102,7 +108,9 @@ discard block |
||
102 | 108 | |
103 | 109 | public function getEdit($id) |
104 | 110 | { |
105 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
111 | + if(!module()->canUpdate()) { |
|
112 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
113 | + } |
|
106 | 114 | |
107 | 115 | $data = []; |
108 | 116 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -113,7 +121,9 @@ discard block |
||
113 | 121 | |
114 | 122 | public function postEditSave($id) |
115 | 123 | { |
116 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
124 | + if(!module()->canUpdate()) { |
|
125 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
126 | + } |
|
117 | 127 | |
118 | 128 | try { |
119 | 129 | $this->validation(); |
@@ -162,7 +172,9 @@ discard block |
||
162 | 172 | |
163 | 173 | public function getDelete($id) |
164 | 174 | { |
165 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
175 | + if(!module()->canDelete()) { |
|
176 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
177 | + } |
|
166 | 178 | |
167 | 179 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
168 | 180 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -189,7 +201,9 @@ discard block |
||
189 | 201 | |
190 | 202 | public function getDetail($id) |
191 | 203 | { |
192 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
204 | + if(!module()->canRead()) { |
|
205 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
206 | + } |
|
193 | 207 | |
194 | 208 | $data = []; |
195 | 209 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |
@@ -212,10 +226,10 @@ discard block |
||
212 | 226 | $key = $parameters[0]; |
213 | 227 | if(isset($this->data[$key])) { |
214 | 228 | return $this->data[$key]; |
215 | - }else{ |
|
229 | + } else{ |
|
216 | 230 | return null; |
217 | 231 | } |
218 | - }else{ |
|
232 | + } else{ |
|
219 | 233 | return null; |
220 | 234 | } |
221 | 235 | } |
@@ -18,14 +18,14 @@ |
||
18 | 18 | */ |
19 | 19 | public function columnIntervention() |
20 | 20 | { |
21 | - if(request("sub_module") && Cache::has("subModule".request("sub_module")) && cb()->getCurrentMethod() != "getDetail") { |
|
21 | + if (request("sub_module") && Cache::has("subModule".request("sub_module")) && cb()->getCurrentMethod() != "getDetail") { |
|
22 | 22 | /* |
23 | 23 | * If there is sub module, the column that has same name with foreign key should be remove |
24 | 24 | * And change to hidden. So we can save the foreign Key id from the parent module. |
25 | 25 | */ |
26 | 26 | $subModule = Cache::get("subModule".request("sub_module")); |
27 | 27 | $this->removeColumn($subModule["foreignKey"]) |
28 | - ->addHidden($subModule["foreignKey"],$subModule['foreignKey']) |
|
28 | + ->addHidden($subModule["foreignKey"], $subModule['foreignKey']) |
|
29 | 29 | ->defaultValue($subModule['foreignValue']); |
30 | 30 | } |
31 | 31 | } |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | $parentPath = $this->getData("permalink"); |
203 | 203 | $parentTitle = $this->getData("page_title"); |
204 | 204 | $this->addActionButton($label,function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) { |
205 | - $actionParameters = [ |
|
206 | - "label"=>$label, |
|
207 | - "foreignKey"=>$foreignKey, |
|
208 | - "foreignValue"=>$row->primary_key, |
|
209 | - "parentPath"=>$parentPath, |
|
210 | - "parentTitle"=>$parentTitle |
|
211 | - ]; |
|
205 | + $actionParameters = [ |
|
206 | + "label"=>$label, |
|
207 | + "foreignKey"=>$foreignKey, |
|
208 | + "foreignValue"=>$row->primary_key, |
|
209 | + "parentPath"=>$parentPath, |
|
210 | + "parentTitle"=>$parentTitle |
|
211 | + ]; |
|
212 | 212 | |
213 | 213 | if(isset($additionalInfo) && is_callable($additionalInfo)) { |
214 | 214 | $additionalInfo = call_user_func($additionalInfo, $row); |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - $actionHash = md5(serialize($actionParameters)); |
|
221 | - $actionHashToken = Cache::get("subModule".$actionHash); |
|
222 | - if(!$actionHashToken) { |
|
223 | - $actionHashToken = Str::random(5); |
|
224 | - Cache::forever("subModule".$actionHash, $actionHashToken); |
|
225 | - Cache::forever("subModule".$actionHashToken, $actionParameters); |
|
226 | - } |
|
220 | + $actionHash = md5(serialize($actionParameters)); |
|
221 | + $actionHashToken = Cache::get("subModule".$actionHash); |
|
222 | + if(!$actionHashToken) { |
|
223 | + $actionHashToken = Str::random(5); |
|
224 | + Cache::forever("subModule".$actionHash, $actionHashToken); |
|
225 | + Cache::forever("subModule".$actionHashToken, $actionParameters); |
|
226 | + } |
|
227 | 227 | |
228 | - return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle); |
|
228 | + return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle); |
|
229 | 229 | }, $condition, $font, $color); |
230 | 230 | |
231 | 231 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | $this->setButtonDetail(true); |
33 | 33 | $this->setButtonSave(true); |
34 | 34 | $this->setButtonLimitPage(true); |
35 | - $this->hideButtonDeleteWhen(function ($row) { return false; }); |
|
36 | - $this->hideButtonDetailWhen(function ($row) { return false; }); |
|
37 | - $this->hideButtonEditWhen(function ($row) { return false; }); |
|
38 | - $this->style(function () { return null; }); |
|
39 | - $this->javascript(function () { return null; }); |
|
35 | + $this->hideButtonDeleteWhen(function($row) { return false; }); |
|
36 | + $this->hideButtonDetailWhen(function($row) { return false; }); |
|
37 | + $this->hideButtonEditWhen(function($row) { return false; }); |
|
38 | + $this->style(function() { return null; }); |
|
39 | + $this->javascript(function() { return null; }); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function style(callable $style) { |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | * @param ButtonColor $color |
141 | 141 | * @param string $attributes |
142 | 142 | */ |
143 | - public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null) |
|
143 | + public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null) |
|
144 | 144 | { |
145 | - $color = ($color)?:ButtonColor::DARK_BLUE; |
|
145 | + $color = ($color) ?: ButtonColor::DARK_BLUE; |
|
146 | 146 | |
147 | 147 | $model = new IndexActionButtonModel(); |
148 | 148 | $model->setLabel($label); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | public function addSubModule($label, $controllerName, $foreignKey, callable $additionalInfo = null, callable $condition = null, $font = null, $color = null) { |
202 | 202 | $parentPath = $this->getData("permalink"); |
203 | 203 | $parentTitle = $this->getData("page_title"); |
204 | - $this->addActionButton($label,function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) { |
|
204 | + $this->addActionButton($label, function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) { |
|
205 | 205 | $actionParameters = [ |
206 | 206 | "label"=>$label, |
207 | 207 | "foreignKey"=>$foreignKey, |
@@ -210,22 +210,22 @@ discard block |
||
210 | 210 | "parentTitle"=>$parentTitle |
211 | 211 | ]; |
212 | 212 | |
213 | - if(isset($additionalInfo) && is_callable($additionalInfo)) { |
|
213 | + if (isset($additionalInfo) && is_callable($additionalInfo)) { |
|
214 | 214 | $additionalInfo = call_user_func($additionalInfo, $row); |
215 | - if(is_array($additionalInfo)) { |
|
215 | + if (is_array($additionalInfo)) { |
|
216 | 216 | $actionParameters['info'] = $additionalInfo; |
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | 220 | $actionHash = md5(serialize($actionParameters)); |
221 | 221 | $actionHashToken = Cache::get("subModule".$actionHash); |
222 | - if(!$actionHashToken) { |
|
222 | + if (!$actionHashToken) { |
|
223 | 223 | $actionHashToken = Str::random(5); |
224 | 224 | Cache::forever("subModule".$actionHash, $actionHashToken); |
225 | 225 | Cache::forever("subModule".$actionHashToken, $actionParameters); |
226 | 226 | } |
227 | 227 | |
228 | - return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle); |
|
228 | + return action(class_basename($controllerName)."@getSubModule", ['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle); |
|
229 | 229 | }, $condition, $font, $color); |
230 | 230 | |
231 | 231 | } |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | * @param $fontAwesome_icon |
239 | 239 | * @param ButtonColor|string $color |
240 | 240 | */ |
241 | - public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false) |
|
241 | + public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false) |
|
242 | 242 | { |
243 | 243 | $new = new AddActionButtonModel(); |
244 | 244 | $new->setLabel($label); |
245 | - $new->setIcon($fontAwesome_icon?:"fa fa-bars"); |
|
246 | - $new->setColor($color?:"primary"); |
|
245 | + $new->setIcon($fontAwesome_icon ?: "fa fa-bars"); |
|
246 | + $new->setColor($color ?: "primary"); |
|
247 | 247 | $new->setUrl($url_target); |
248 | 248 | $new->setCondition($condition_callback); |
249 | 249 | $new->setConfirmation($confirmation); |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | |
25 | 25 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
26 | 26 | |
27 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
28 | - if($softDelete === true && SchemaHelper::hasColumn($this->data['table'],'deleted_at')) { |
|
27 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
28 | + if ($softDelete === true && SchemaHelper::hasColumn($this->data['table'], 'deleted_at')) { |
|
29 | 29 | $query->whereNull($this->data['table'].'.deleted_at'); |
30 | 30 | } |
31 | 31 | |
32 | - if(isset($joins)) { |
|
33 | - foreach($joins as $join) |
|
32 | + if (isset($joins)) { |
|
33 | + foreach ($joins as $join) |
|
34 | 34 | { |
35 | 35 | $query->join($join['target_table'], |
36 | 36 | $join['target_table_primary'], |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | - foreach($columns as $column) { |
|
43 | + foreach ($columns as $column) { |
|
44 | 44 | /** @var ColumnModel $column */ |
45 | - if($column->getType() != "custom") { |
|
46 | - if(strpos($column->getField(),".") === false) { |
|
47 | - if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
45 | + if ($column->getType() != "custom") { |
|
46 | + if (strpos($column->getField(), ".") === false) { |
|
47 | + if (SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
48 | 48 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
49 | 49 | } |
50 | - }else{ |
|
50 | + } else { |
|
51 | 51 | $query->addSelect($column->getField()); |
52 | 52 | } |
53 | 53 | } |
@@ -55,20 +55,20 @@ discard block |
||
55 | 55 | $query = getTypeHook($column->getType())->query($query, $column); |
56 | 56 | } |
57 | 57 | |
58 | - if(request()->has('q')) |
|
58 | + if (request()->has('q')) |
|
59 | 59 | { |
60 | - if(isset($this->data['hook_search_query'])) { |
|
60 | + if (isset($this->data['hook_search_query'])) { |
|
61 | 61 | $query = call_user_func($this->data['hook_search_query'], $query); |
62 | - }else{ |
|
63 | - $query->where(function ($where) use ($columns) { |
|
62 | + } else { |
|
63 | + $query->where(function($where) use ($columns) { |
|
64 | 64 | /** |
65 | 65 | * @var $where Builder |
66 | 66 | */ |
67 | - foreach($columns as $column) |
|
67 | + foreach ($columns as $column) |
|
68 | 68 | { |
69 | - if(strpos($column->getField(),".") === false) { |
|
69 | + if (strpos($column->getField(), ".") === false) { |
|
70 | 70 | $field = $this->data['table'].'.'.$column->getField(); |
71 | - }else{ |
|
71 | + } else { |
|
72 | 72 | $field = $column->getField(); |
73 | 73 | } |
74 | 74 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -79,21 +79,21 @@ discard block |
||
79 | 79 | |
80 | 80 | |
81 | 81 | // Callback From this Method |
82 | - if(isset($callback) && is_callable($callback)) { |
|
82 | + if (isset($callback) && is_callable($callback)) { |
|
83 | 83 | $query = call_user_func($callback, $query); |
84 | 84 | } |
85 | 85 | |
86 | - if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
86 | + if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
87 | 87 | $query = call_user_func($this->data['hook_index_query'], $query); |
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | - if(request()->has(['order_by','order_sort'])) |
|
91 | + if (request()->has(['order_by', 'order_sort'])) |
|
92 | 92 | { |
93 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
93 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
94 | 94 | $query->orderBy(request('order_by'), request('order_sort')); |
95 | 95 | } |
96 | - }else{ |
|
96 | + } else { |
|
97 | 97 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
98 | 98 | } |
99 | 99 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
48 | 48 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
49 | 49 | } |
50 | - }else{ |
|
50 | + } else{ |
|
51 | 51 | $query->addSelect($column->getField()); |
52 | 52 | } |
53 | 53 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | if(isset($this->data['hook_search_query'])) { |
61 | 61 | $query = call_user_func($this->data['hook_search_query'], $query); |
62 | - }else{ |
|
62 | + } else{ |
|
63 | 63 | $query->where(function ($where) use ($columns) { |
64 | 64 | /** |
65 | 65 | * @var $where Builder |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | if(strpos($column->getField(),".") === false) { |
70 | 70 | $field = $this->data['table'].'.'.$column->getField(); |
71 | - }else{ |
|
71 | + } else{ |
|
72 | 72 | $field = $column->getField(); |
73 | 73 | } |
74 | 74 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
94 | 94 | $query->orderBy(request('order_by'), request('order_sort')); |
95 | 95 | } |
96 | - }else{ |
|
96 | + } else{ |
|
97 | 97 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
98 | 98 | } |
99 | 99 |
@@ -19,12 +19,12 @@ |
||
19 | 19 | */ |
20 | 20 | private function validation() |
21 | 21 | { |
22 | - if(isset($this->data['validation'])) { |
|
22 | + if (isset($this->data['validation'])) { |
|
23 | 23 | $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']); |
24 | 24 | if ($validator->fails()) { |
25 | 25 | $message = $validator->messages(); |
26 | 26 | $message_all = $message->all(); |
27 | - throw new CBValidationException(implode(', ',$message_all)); |
|
27 | + throw new CBValidationException(implode(', ', $message_all)); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | } |