@@ -57,7 +57,7 @@ |
||
| 57 | 57 | <label>Dashboard Controller</label> |
| 58 | 58 | <select name="dashboard_controller" class="form-control"> |
| 59 | 59 | <option value="">** Default CB</option> |
| 60 | - <?php $controllers = glob(app_path("Http/Controllers/*Controller.php"));?> |
|
| 60 | + <?php $controllers = glob(app_path("Http/Controllers/*Controller.php")); ?> |
|
| 61 | 61 | @foreach($controllers as $controller) |
| 62 | 62 | @if(basename($controller) != "Controller.php") |
| 63 | 63 | <option {{ getSetting("dashboard_controller")==rtrim(basename($controller),".php")?"selected":"" }} value="{{ rtrim(basename($controller),".php") }}">{{ rtrim(basename($controller),".php") }}</option> |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | // Direct return value because its been uploaded on client side |
| 25 | 25 | $ext = strtolower(pathinfo($value, PATHINFO_EXTENSION)); |
| 26 | - if(in_array($ext, cbConfig("UPLOAD_IMAGE_EXTENSION_ALLOWED"))) { |
|
| 26 | + if (in_array($ext, cbConfig("UPLOAD_IMAGE_EXTENSION_ALLOWED"))) { |
|
| 27 | 27 | return $value; |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function detailRender($row, $column) |
| 32 | 32 | { |
| 33 | 33 | $column->setValue($row->{ $column->getField() }); |
| 34 | - return view("types::image.detail",[ |
|
| 34 | + return view("types::image.detail", [ |
|
| 35 | 35 | 'row'=>$row, |
| 36 | 36 | 'column'=>$column |
| 37 | 37 | ]); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function indexRender($row, $column) |
| 41 | 41 | { |
| 42 | 42 | $column->setValue($row->{ $column->getField() }); |
| 43 | - return view("types::image.index",[ |
|
| 43 | + return view("types::image.index", [ |
|
| 44 | 44 | 'row'=>$row, |
| 45 | 45 | 'column'=>$column |
| 46 | 46 | ]); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function assignment($value, $column) |
| 23 | 23 | { |
| 24 | 24 | $ext = strtolower(pathinfo($value, PATHINFO_EXTENSION)); |
| 25 | - if(in_array($ext, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
| 25 | + if (in_array($ext, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
| 26 | 26 | return $value; |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | public function detailRender($row, $column) |
| 31 | 31 | { |
| 32 | 32 | $column->setValue($row->{ $column->getField() }); |
| 33 | - return view("types::file.detail",[ |
|
| 33 | + return view("types::file.detail", [ |
|
| 34 | 34 | 'row'=>$row, |
| 35 | 35 | 'column'=>$column |
| 36 | 36 | ]); |
@@ -3,64 +3,64 @@ discard block |
||
| 3 | 3 | /* |
| 4 | 4 | * Theme Helper |
| 5 | 5 | */ |
| 6 | -if(!function_exists("themeLoginBackground")) { |
|
| 6 | +if (!function_exists("themeLoginBackground")) { |
|
| 7 | 7 | function themeLoginBackground() { |
| 8 | 8 | return "crudbooster::layouts.login_background_css"; |
| 9 | 9 | } |
| 10 | 10 | } |
| 11 | -if(!function_exists("themeFlashMessageAlert")) { |
|
| 11 | +if (!function_exists("themeFlashMessageAlert")) { |
|
| 12 | 12 | function themeFlashMessageAlert() { |
| 13 | 13 | return "crudbooster::layouts.flash_message_alert"; |
| 14 | 14 | } |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -if(!function_exists("themeFlashMessage")) { |
|
| 17 | +if (!function_exists("themeFlashMessage")) { |
|
| 18 | 18 | function themeFlashMessage() { |
| 19 | 19 | return "crudbooster::layouts.flash_message"; |
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -if(!function_exists("themeAlertMessage")) { |
|
| 23 | +if (!function_exists("themeAlertMessage")) { |
|
| 24 | 24 | function themeAlertMessage() { |
| 25 | 25 | return "crudbooster::layouts.alert_message"; |
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -if(!function_exists("themeLayoutPageTitleAndButton")) { |
|
| 29 | +if (!function_exists("themeLayoutPageTitleAndButton")) { |
|
| 30 | 30 | function themeLayoutPageTitleAndButton() { |
| 31 | 31 | return 'crudbooster::module.index.index_head_buttons'; |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | -if(!function_exists("themeLayoutHead")) { |
|
| 35 | +if (!function_exists("themeLayoutHead")) { |
|
| 36 | 36 | function themeLayoutHead() { |
| 37 | 37 | return "crudbooster::layouts.head"; |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | -if(!function_exists("themeTitle")) { |
|
| 40 | +if (!function_exists("themeTitle")) { |
|
| 41 | 41 | function themeTitle($page_title) { |
| 42 | - $page_title = isset($page_title)?$page_title:module()->getPageTitle(); |
|
| 43 | - return (isset($page_title))?cb()->getAppName().': '.strip_tags($page_title):"Admin Area"; |
|
| 42 | + $page_title = isset($page_title) ? $page_title : module()->getPageTitle(); |
|
| 43 | + return (isset($page_title)) ?cb()->getAppName().': '.strip_tags($page_title) : "Admin Area"; |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -if(!function_exists("getThemePath")) { |
|
| 47 | +if (!function_exists("getThemePath")) { |
|
| 48 | 48 | function getThemePath($path = null) { |
| 49 | - return getSetting("theme_path", "crudbooster::themes.adminlte").(($path)?".".$path:null); |
|
| 49 | + return getSetting("theme_path", "crudbooster::themes.adminlte").(($path) ? ".".$path : null); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // End Theme Helper |
| 54 | 54 | |
| 55 | -if(!function_exists("isConfigCached")) { |
|
| 55 | +if (!function_exists("isConfigCached")) { |
|
| 56 | 56 | function isConfigCached() |
| 57 | 57 | { |
| 58 | - if(env("APP_NAME")=="" || env("APP_NAME")==null) return true; |
|
| 58 | + if (env("APP_NAME") == "" || env("APP_NAME") == null) return true; |
|
| 59 | 59 | else return false; |
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | -if(!function_exists("miscellanousSingleton")) { |
|
| 63 | +if (!function_exists("miscellanousSingleton")) { |
|
| 64 | 64 | /** |
| 65 | 65 | * @return \crocodicstudio\crudbooster\helpers\MiscellanousSingleton |
| 66 | 66 | */ |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | -if(!function_exists("makeReferalUrl")) { |
|
| 72 | +if (!function_exists("makeReferalUrl")) { |
|
| 73 | 73 | function makeReferalUrl($name = null) { |
| 74 | 74 | $ref = []; |
| 75 | 75 | $ref['url'] = request()->fullUrl(); |
| 76 | 76 | $ref['name'] = $name; |
| 77 | 77 | $md5Hash = md5(serialize($ref)); |
| 78 | 78 | |
| 79 | - if($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) { |
|
| 79 | + if ($exist = \Illuminate\Support\Facades\Cache::get("refurl_".$md5Hash)) { |
|
| 80 | 80 | return $exist['id']; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | -if(!function_exists("getReferalUrl")) { |
|
| 91 | +if (!function_exists("getReferalUrl")) { |
|
| 92 | 92 | function getReferalUrl($key = null) { |
| 93 | - if(verifyReferalUrl()) { |
|
| 93 | + if (verifyReferalUrl()) { |
|
| 94 | 94 | $md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref")); |
| 95 | 95 | $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash); |
| 96 | - if($key) { |
|
| 96 | + if ($key) { |
|
| 97 | 97 | return @$ref[$key]; |
| 98 | 98 | } else { |
| 99 | 99 | return $ref; |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | -if(!function_exists("verifyReferalUrl")) { |
|
| 106 | +if (!function_exists("verifyReferalUrl")) { |
|
| 107 | 107 | function verifyReferalUrl() |
| 108 | 108 | { |
| 109 | - if(request("ref")) { |
|
| 110 | - if($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) { |
|
| 109 | + if (request("ref")) { |
|
| 110 | + if ($md5hash = \Illuminate\Support\Facades\Cache::get("refurl_token_".request("ref"))) { |
|
| 111 | 111 | $ref = \Illuminate\Support\Facades\Cache::get("refurl_".$md5hash); |
| 112 | - if(filter_var($ref['url'], FILTER_VALIDATE_URL)) { |
|
| 112 | + if (filter_var($ref['url'], FILTER_VALIDATE_URL)) { |
|
| 113 | 113 | return true; |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | -if(!function_exists("putHtaccess")) { |
|
| 121 | +if (!function_exists("putHtaccess")) { |
|
| 122 | 122 | function putHtaccess($stringToPut) |
| 123 | 123 | { |
| 124 | 124 | file_put_contents(base_path(".htaccess"), "\n".$stringToPut, FILE_APPEND); |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | -if(!function_exists("checkHtaccess")) { |
|
| 129 | +if (!function_exists("checkHtaccess")) { |
|
| 130 | 130 | function checkHtaccess($stringToCheck) |
| 131 | 131 | { |
| 132 | - if(file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) { |
|
| 132 | + if (file_exists(base_path(".htaccess")) && file_exists(public_path(".htaccess"))) { |
|
| 133 | 133 | $htaccess = file_get_contents(base_path(".htaccess")); |
| 134 | - $htaccess2= file_get_contents(public_path(".htaccess")); |
|
| 135 | - if(\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) { |
|
| 134 | + $htaccess2 = file_get_contents(public_path(".htaccess")); |
|
| 135 | + if (\Illuminate\Support\Str::contains($htaccess, $stringToCheck) && \Illuminate\Support\Str::contains($htaccess2, $stringToCheck)) { |
|
| 136 | 136 | return true; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | -if(!function_exists("setEnvironmentValue")) { |
|
| 144 | +if (!function_exists("setEnvironmentValue")) { |
|
| 145 | 145 | function setEnvironmentValue(array $values) |
| 146 | 146 | { |
| 147 | 147 | $envFile = app()->environmentFilePath(); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
| 175 | -if(!function_exists("cbLang")) { |
|
| 175 | +if (!function_exists("cbLang")) { |
|
| 176 | 176 | /** |
| 177 | 177 | * @param string $key |
| 178 | 178 | * @param array $replace |
@@ -184,17 +184,17 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | -if(!function_exists('rglob')) { |
|
| 187 | +if (!function_exists('rglob')) { |
|
| 188 | 188 | function rglob($pattern, $flags = 0) { |
| 189 | 189 | $files = glob($pattern, $flags); |
| 190 | - foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) { |
|
| 190 | + foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
|
| 191 | 191 | $files = array_merge($files, rglob($dir.'/'.basename($pattern), $flags)); |
| 192 | 192 | } |
| 193 | 193 | return $files; |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | -if(!function_exists('convertPHPToMomentFormat')) { |
|
| 197 | +if (!function_exists('convertPHPToMomentFormat')) { |
|
| 198 | 198 | function convertPHPToMomentFormat($format) |
| 199 | 199 | { |
| 200 | 200 | $replacements = [ |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | -if(!function_exists('slug')) { |
|
| 244 | +if (!function_exists('slug')) { |
|
| 245 | 245 | function slug($string, $separator = '-') { |
| 246 | 246 | return \Illuminate\Support\Str::slug($string, $separator); |
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | -if(!function_exists('columnSingleton')) { |
|
| 250 | +if (!function_exists('columnSingleton')) { |
|
| 251 | 251 | /** |
| 252 | 252 | * @return \crocodicstudio\crudbooster\controllers\scaffolding\singletons\ColumnSingleton |
| 253 | 253 | */ |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | -if(!function_exists('cbHook')) |
|
| 259 | +if (!function_exists('cbHook')) |
|
| 260 | 260 | { |
| 261 | 261 | /** |
| 262 | 262 | * @return crocodicstudio\crudbooster\hooks\CBHook |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | -if(!function_exists('getTypeHook')) |
|
| 271 | +if (!function_exists('getTypeHook')) |
|
| 272 | 272 | { |
| 273 | 273 | /** |
| 274 | 274 | * @param string $type |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | -if(!function_exists('getPrimaryKey')) |
|
| 284 | +if (!function_exists('getPrimaryKey')) |
|
| 285 | 285 | { |
| 286 | 286 | function getPrimaryKey($table_name) |
| 287 | 287 | { |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | -if(!function_exists('cb')) |
|
| 292 | +if (!function_exists('cb')) |
|
| 293 | 293 | { |
| 294 | 294 | function cb() |
| 295 | 295 | { |
@@ -297,30 +297,30 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | -if(!function_exists("cbAssetPath")) { |
|
| 300 | +if (!function_exists("cbAssetPath")) { |
|
| 301 | 301 | function cbAssetPath($path = null) { |
| 302 | - return "cb_asset".(($path)?"/".$path:null); |
|
| 302 | + return "cb_asset".(($path) ? "/".$path : null); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | -if(!function_exists('cbAsset')) { |
|
| 305 | +if (!function_exists('cbAsset')) { |
|
| 306 | 306 | function cbAsset($path, $secure = null) { |
| 307 | 307 | return asset(cbAssetPath()."/".$path, $secure); |
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | -if(!function_exists("cbConfig")) { |
|
| 311 | +if (!function_exists("cbConfig")) { |
|
| 312 | 312 | function cbConfig($name, $default = null) { |
| 313 | 313 | return config("crudbooster.".$name, $default); |
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | -if(!function_exists("strRandom")) { |
|
| 317 | +if (!function_exists("strRandom")) { |
|
| 318 | 318 | function strRandom($length = 5) { |
| 319 | 319 | return \Illuminate\Support\Str::random($length); |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | -if(!function_exists('module')) { |
|
| 323 | +if (!function_exists('module')) { |
|
| 324 | 324 | function module() |
| 325 | 325 | { |
| 326 | 326 | $module = new \crocodicstudio\crudbooster\helpers\Module(); |
@@ -328,21 +328,21 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | -if(!function_exists('getAdminLoginURL')) { |
|
| 331 | +if (!function_exists('getAdminLoginURL')) { |
|
| 332 | 332 | function getAdminLoginURL() |
| 333 | 333 | { |
| 334 | 334 | return cb()->getAdminUrl("login"); |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | -if(!function_exists('dummyPhoto')) { |
|
| 338 | +if (!function_exists('dummyPhoto')) { |
|
| 339 | 339 | function dummyPhoto() |
| 340 | 340 | { |
| 341 | - return getSetting("dummy_photo","cb_asset/images/user8-128x128.jpg"); |
|
| 341 | + return getSetting("dummy_photo", "cb_asset/images/user8-128x128.jpg"); |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | -if(!function_exists('extract_unit')) { |
|
| 345 | +if (!function_exists('extract_unit')) { |
|
| 346 | 346 | /* |
| 347 | 347 | Credits: Bit Repository |
| 348 | 348 | URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html |
@@ -367,14 +367,14 @@ discard block |
||
| 367 | 367 | | |
| 368 | 368 | */ |
| 369 | 369 | |
| 370 | -if(!function_exists('putSetting')) { |
|
| 370 | +if (!function_exists('putSetting')) { |
|
| 371 | 371 | function putSetting($key, $value) |
| 372 | 372 | { |
| 373 | - if(file_exists(storage_path('.cbconfig'))) { |
|
| 373 | + if (file_exists(storage_path('.cbconfig'))) { |
|
| 374 | 374 | $settings = file_get_contents(storage_path('.cbconfig')); |
| 375 | 375 | $settings = decrypt($settings); |
| 376 | 376 | $settings = unserialize($settings); |
| 377 | - }else{ |
|
| 377 | + } else { |
|
| 378 | 378 | $settings = []; |
| 379 | 379 | } |
| 380 | 380 | |
@@ -388,31 +388,31 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | -if(!function_exists('getSetting')) { |
|
| 391 | +if (!function_exists('getSetting')) { |
|
| 392 | 392 | function getSetting($key, $default = null) |
| 393 | 393 | { |
| 394 | - if($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) { |
|
| 394 | + if ($cache = \Illuminate\Support\Facades\Cache::get("setting_".$key)) { |
|
| 395 | 395 | return $cache; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - if(file_exists(storage_path('.cbconfig'))) { |
|
| 398 | + if (file_exists(storage_path('.cbconfig'))) { |
|
| 399 | 399 | $settings = file_get_contents(storage_path('.cbconfig')); |
| 400 | 400 | $settings = decrypt($settings); |
| 401 | 401 | $settings = unserialize($settings); |
| 402 | - }else{ |
|
| 402 | + } else { |
|
| 403 | 403 | $settings = []; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - if(isset($settings[$key])) { |
|
| 406 | + if (isset($settings[$key])) { |
|
| 407 | 407 | \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]); |
| 408 | - return $settings[$key]?:$default; |
|
| 409 | - }else{ |
|
| 408 | + return $settings[$key] ?: $default; |
|
| 409 | + } else { |
|
| 410 | 410 | return $default; |
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | -if(!function_exists('timeAgo')) { |
|
| 415 | +if (!function_exists('timeAgo')) { |
|
| 416 | 416 | function timeAgo($datetime_to, $datetime_from = null, $full = false) |
| 417 | 417 | { |
| 418 | 418 | $datetime_from = ($datetime_from) ?: date('Y-m-d H:i:s'); |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - if (! $full) { |
|
| 446 | + if (!$full) { |
|
| 447 | 447 | $string = array_slice($string, 0, 1); |
| 448 | 448 | } |
| 449 | 449 | |
@@ -451,22 +451,22 @@ discard block |
||
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | -if(!function_exists("array_map_r")) { |
|
| 455 | - function array_map_r( $func, $arr ) |
|
| 454 | +if (!function_exists("array_map_r")) { |
|
| 455 | + function array_map_r($func, $arr) |
|
| 456 | 456 | { |
| 457 | 457 | $newArr = array(); |
| 458 | 458 | |
| 459 | - foreach( $arr as $key => $value ) |
|
| 459 | + foreach ($arr as $key => $value) |
|
| 460 | 460 | { |
| 461 | 461 | $key = $func($key); |
| 462 | - $newArr[ $key ] = ( is_array( $value ) ? array_map_r( $func, $value ) : ( is_array($func) ? call_user_func_array($func, $value) : $func( $value ) ) ); |
|
| 462 | + $newArr[$key] = (is_array($value) ? array_map_r($func, $value) : (is_array($func) ? call_user_func_array($func, $value) : $func($value))); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | return $newArr; |
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | -if(!function_exists("sanitizeXSS")) |
|
| 469 | +if (!function_exists("sanitizeXSS")) |
|
| 470 | 470 | { |
| 471 | 471 | function sanitizeXSS($value) |
| 472 | 472 | { |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | -if(!function_exists("requestAll")) { |
|
| 481 | +if (!function_exists("requestAll")) { |
|
| 482 | 482 | function requestAll() { |
| 483 | 483 | $all = array_map_r("sanitizeXSS", request()->all()); |
| 484 | 484 | return $all; |
@@ -487,22 +487,22 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | |
| 490 | -if(!function_exists('getURLFormat')) { |
|
| 490 | +if (!function_exists('getURLFormat')) { |
|
| 491 | 491 | function getURLFormat($name) { |
| 492 | 492 | $url = request($name); |
| 493 | - if(filter_var($url, FILTER_VALIDATE_URL)) { |
|
| 493 | + if (filter_var($url, FILTER_VALIDATE_URL)) { |
|
| 494 | 494 | return $url; |
| 495 | - }else{ |
|
| 495 | + } else { |
|
| 496 | 496 | return request()->url(); |
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | -if(!function_exists('g')) { |
|
| 501 | +if (!function_exists('g')) { |
|
| 502 | 502 | function g($name, $safe = true) { |
| 503 | - if($safe == true) { |
|
| 503 | + if ($safe == true) { |
|
| 504 | 504 | $response = request($name); |
| 505 | - if(is_string($response)) { |
|
| 505 | + if (is_string($response)) { |
|
| 506 | 506 | $response = sanitizeXSS($response); |
| 507 | 507 | }elseif (is_array($response)) { |
| 508 | 508 | array_walk_recursive($response, function(&$response) { |
@@ -511,25 +511,25 @@ discard block |
||
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | return $response; |
| 514 | - }else{ |
|
| 514 | + } else { |
|
| 515 | 515 | return Request::get($name); |
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | -if(!function_exists('min_var_export')) { |
|
| 520 | +if (!function_exists('min_var_export')) { |
|
| 521 | 521 | function min_var_export($input) { |
| 522 | - if(is_array($input)) { |
|
| 522 | + if (is_array($input)) { |
|
| 523 | 523 | $buffer = []; |
| 524 | - foreach($input as $key => $value) |
|
| 524 | + foreach ($input as $key => $value) |
|
| 525 | 525 | $buffer[] = var_export($key, true)."=>".min_var_export($value); |
| 526 | - return "[".implode(",",$buffer)."]"; |
|
| 526 | + return "[".implode(",", $buffer)."]"; |
|
| 527 | 527 | } else |
| 528 | 528 | return var_export($input, true); |
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | -if(!function_exists('rrmdir')) { |
|
| 532 | +if (!function_exists('rrmdir')) { |
|
| 533 | 533 | /* |
| 534 | 534 | * http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir |
| 535 | 535 | */ |
@@ -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")?:$this->data['limit'] ); |
|
| 38 | + $result = $query->paginate(request("limit") ?: $this->data['limit']); |
|
| 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'], $data, $id); |
| 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")?:$this->data['limit'] ); |
@@ -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 | } |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | $this->setButtonDetail(true); |
| 34 | 34 | $this->setButtonSave(true); |
| 35 | 35 | $this->setButtonLimitPage(true); |
| 36 | - $this->hideButtonDeleteWhen(function ($row) { return false; }); |
|
| 37 | - $this->hideButtonDetailWhen(function ($row) { return false; }); |
|
| 38 | - $this->hideButtonEditWhen(function ($row) { return false; }); |
|
| 39 | - $this->style(function () { return null; }); |
|
| 40 | - $this->javascript(function () { return null; }); |
|
| 36 | + $this->hideButtonDeleteWhen(function($row) { return false; }); |
|
| 37 | + $this->hideButtonDetailWhen(function($row) { return false; }); |
|
| 38 | + $this->hideButtonEditWhen(function($row) { return false; }); |
|
| 39 | + $this->style(function() { return null; }); |
|
| 40 | + $this->javascript(function() { return null; }); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function appendAddForm(callable $html) { |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | * @param ButtonColor $color |
| 158 | 158 | * @param string $attributes |
| 159 | 159 | */ |
| 160 | - public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null) |
|
| 160 | + public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null) |
|
| 161 | 161 | { |
| 162 | - $color = ($color)?:ButtonColor::DARK_BLUE; |
|
| 162 | + $color = ($color) ?: ButtonColor::DARK_BLUE; |
|
| 163 | 163 | |
| 164 | 164 | $model = new IndexActionButtonModel(); |
| 165 | 165 | $model->setLabel($label); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | public function addSubModule($label, $controllerName, $foreignKey, callable $additionalInfo = null, callable $condition = null, $font = null, $color = null) { |
| 219 | 219 | $parentPath = $this->getData("permalink"); |
| 220 | 220 | $parentTitle = $this->getData("page_title"); |
| 221 | - $this->addActionButton($label,function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) { |
|
| 221 | + $this->addActionButton($label, function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) { |
|
| 222 | 222 | $actionParameters = [ |
| 223 | 223 | "label"=>$label, |
| 224 | 224 | "foreignKey"=>$foreignKey, |
@@ -227,22 +227,22 @@ discard block |
||
| 227 | 227 | "parentTitle"=>$parentTitle |
| 228 | 228 | ]; |
| 229 | 229 | |
| 230 | - if(isset($additionalInfo) && is_callable($additionalInfo)) { |
|
| 230 | + if (isset($additionalInfo) && is_callable($additionalInfo)) { |
|
| 231 | 231 | $additionalInfo = call_user_func($additionalInfo, $row); |
| 232 | - if(is_array($additionalInfo)) { |
|
| 232 | + if (is_array($additionalInfo)) { |
|
| 233 | 233 | $actionParameters['info'] = $additionalInfo; |
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $actionHash = md5(serialize($actionParameters)); |
| 238 | 238 | $actionHashToken = Cache::get("subModule".$actionHash); |
| 239 | - if(!$actionHashToken) { |
|
| 239 | + if (!$actionHashToken) { |
|
| 240 | 240 | $actionHashToken = Str::random(5); |
| 241 | 241 | Cache::forever("subModule".$actionHash, $actionHashToken); |
| 242 | 242 | Cache::forever("subModule".$actionHashToken, $actionParameters); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle); |
|
| 245 | + return action(class_basename($controllerName)."@getSubModule", ['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle); |
|
| 246 | 246 | }, $condition, $font, $color); |
| 247 | 247 | |
| 248 | 248 | } |
@@ -255,12 +255,12 @@ discard block |
||
| 255 | 255 | * @param $fontAwesome_icon |
| 256 | 256 | * @param ButtonColor|string $color |
| 257 | 257 | */ |
| 258 | - public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false) |
|
| 258 | + public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false) |
|
| 259 | 259 | { |
| 260 | 260 | $new = new AddActionButtonModel(); |
| 261 | 261 | $new->setLabel($label); |
| 262 | - $new->setIcon($fontAwesome_icon?:"fa fa-bars"); |
|
| 263 | - $new->setColor($color?:"primary"); |
|
| 262 | + $new->setIcon($fontAwesome_icon ?: "fa fa-bars"); |
|
| 263 | + $new->setColor($color ?: "primary"); |
|
| 264 | 264 | $new->setUrl($url_target); |
| 265 | 265 | $new->setCondition($condition_callback); |
| 266 | 266 | $new->setConfirmation($confirmation); |
@@ -1,59 +1,59 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Developer Backend Middleware |
| 4 | -Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
| 4 | +Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
| 5 | 5 | 'prefix'=>"developer/".getSetting('developer_path'), |
| 6 | - 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
| 6 | + 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
| 7 | 7 | cb()->routeController("modules", "\crocodicstudio\crudbooster\controllers\DeveloperModulesController"); |
| 8 | 8 | cb()->routeController("menus", "\crocodicstudio\crudbooster\controllers\DeveloperMenusController"); |
| 9 | - cb()->routeController("roles","\crocodicstudio\crudbooster\controllers\DeveloperRolesController"); |
|
| 10 | - cb()->routeController("users","\crocodicstudio\crudbooster\controllers\DeveloperUsersController"); |
|
| 11 | - cb()->routeController("plugins","\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController"); |
|
| 12 | - cb()->routeController("mail","\crocodicstudio\crudbooster\controllers\DeveloperMailController"); |
|
| 13 | - cb()->routeController("security","\crocodicstudio\crudbooster\controllers\DeveloperSecurityController"); |
|
| 14 | - cb()->routeController("themes","\crocodicstudio\crudbooster\controllers\DeveloperThemesController"); |
|
| 15 | - cb()->routeController("appearance","\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController"); |
|
| 16 | - cb()->routeController("miscellaneous","\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController"); |
|
| 17 | - cb()->routePost("skip-tutorial","DeveloperDashboardController@postSkipTutorial"); |
|
| 18 | - cb()->routeGet("/","DeveloperDashboardController@getIndex"); |
|
| 9 | + cb()->routeController("roles", "\crocodicstudio\crudbooster\controllers\DeveloperRolesController"); |
|
| 10 | + cb()->routeController("users", "\crocodicstudio\crudbooster\controllers\DeveloperUsersController"); |
|
| 11 | + cb()->routeController("plugins", "\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController"); |
|
| 12 | + cb()->routeController("mail", "\crocodicstudio\crudbooster\controllers\DeveloperMailController"); |
|
| 13 | + cb()->routeController("security", "\crocodicstudio\crudbooster\controllers\DeveloperSecurityController"); |
|
| 14 | + cb()->routeController("themes", "\crocodicstudio\crudbooster\controllers\DeveloperThemesController"); |
|
| 15 | + cb()->routeController("appearance", "\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController"); |
|
| 16 | + cb()->routeController("miscellaneous", "\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController"); |
|
| 17 | + cb()->routePost("skip-tutorial", "DeveloperDashboardController@postSkipTutorial"); |
|
| 18 | + cb()->routeGet("/", "DeveloperDashboardController@getIndex"); |
|
| 19 | 19 | }); |
| 20 | 20 | |
| 21 | 21 | // Developer Auth Middleware |
| 22 | 22 | Route::group(['middleware' => ['web'], |
| 23 | 23 | 'prefix'=>"developer/".getSetting('developer_path'), |
| 24 | - 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
| 25 | - cb()->routePost("login","AdminAuthController@postLoginDeveloper"); |
|
| 26 | - cb()->routeGet("login","AdminAuthController@getLoginDeveloper"); |
|
| 27 | - cb()->routeGet("logout","AdminAuthController@getLogoutDeveloper"); |
|
| 24 | + 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
| 25 | + cb()->routePost("login", "AdminAuthController@postLoginDeveloper"); |
|
| 26 | + cb()->routeGet("login", "AdminAuthController@getLoginDeveloper"); |
|
| 27 | + cb()->routeGet("logout", "AdminAuthController@getLogoutDeveloper"); |
|
| 28 | 28 | }); |
| 29 | 29 | |
| 30 | 30 | // Routing without any middleware |
| 31 | -Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () { |
|
| 32 | - if(getSetting("AUTO_REDIRECT_TO_LOGIN")) { |
|
| 33 | - cb()->routeGet("/","AdminAuthController@getRedirectToLogin"); |
|
| 31 | +Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() { |
|
| 32 | + if (getSetting("AUTO_REDIRECT_TO_LOGIN")) { |
|
| 33 | + cb()->routeGet("/", "AdminAuthController@getRedirectToLogin"); |
|
| 34 | 34 | } |
| 35 | 35 | }); |
| 36 | 36 | |
| 37 | 37 | // Routing without any middleware with admin prefix |
| 38 | -Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
| 38 | +Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
| 39 | 39 | cb()->routeGet('logout', "AdminAuthController@getLogout"); |
| 40 | 40 | |
| 41 | - if(!getSetting("DISABLE_LOGIN")) { |
|
| 41 | + if (!getSetting("DISABLE_LOGIN")) { |
|
| 42 | 42 | cb()->routePost('login', "AdminAuthController@postLogin"); |
| 43 | 43 | cb()->routeGet('login', "AdminAuthController@getLogin"); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if(getSetting("enable_forget")) { |
|
| 47 | - cb()->routePost("forget","AdminAuthController@postForget"); |
|
| 46 | + if (getSetting("enable_forget")) { |
|
| 47 | + cb()->routePost("forget", "AdminAuthController@postForget"); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if(getSetting("enable_register")) { |
|
| 51 | - cb()->routePost("register","AdminAuthController@postRegister"); |
|
| 50 | + if (getSetting("enable_register")) { |
|
| 51 | + cb()->routePost("register", "AdminAuthController@postRegister"); |
|
| 52 | 52 | } |
| 53 | 53 | }); |
| 54 | 54 | |
| 55 | 55 | // Routing package controllers |
| 56 | -cb()->routeGroupBackend(function () { |
|
| 56 | +cb()->routeGroupBackend(function() { |
|
| 57 | 57 | cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController'); |
| 58 | 58 | }); |
| 59 | 59 | |
@@ -62,24 +62,24 @@ discard block |
||
| 62 | 62 | 'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class], |
| 63 | 63 | 'prefix' => cb()->getAdminPath(), |
| 64 | 64 | 'namespace' => 'App\Http\Controllers', |
| 65 | -], function () { |
|
| 65 | +], function() { |
|
| 66 | 66 | |
| 67 | 67 | if (Request::is(cb()->getAdminPath())) { |
| 68 | - if($dashboard = getSetting("dashboard_controller")) { |
|
| 68 | + if ($dashboard = getSetting("dashboard_controller")) { |
|
| 69 | 69 | cb()->routeGet("/", $dashboard."@getIndex"); |
| 70 | - }else{ |
|
| 70 | + } else { |
|
| 71 | 71 | cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $controllers = glob(app_path('Http/Controllers/Admin*Controller.php')); |
| 76 | 76 | |
| 77 | - foreach($controllers as $controller) { |
|
| 77 | + foreach ($controllers as $controller) { |
|
| 78 | 78 | $controllerName = basename($controller); |
| 79 | - $controllerName = rtrim($controllerName,".php"); |
|
| 79 | + $controllerName = rtrim($controllerName, ".php"); |
|
| 80 | 80 | $className = '\App\Http\Controllers\\'.$controllerName; |
| 81 | 81 | $controllerClass = new $className(); |
| 82 | - if(method_exists($controllerClass, 'cbInit')) { |
|
| 82 | + if (method_exists($controllerClass, 'cbInit')) { |
|
| 83 | 83 | cb()->routeController($controllerClass->getData('permalink'), $controllerName); |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | if (Request::is(cb()->getAdminPath())) { |
| 68 | 68 | if($dashboard = getSetting("dashboard_controller")) { |
| 69 | 69 | cb()->routeGet("/", $dashboard."@getIndex"); |
| 70 | - }else{ |
|
| 70 | + } else{ |
|
| 71 | 71 | cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
| 72 | 72 | } |
| 73 | 73 | } |