@@ -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 | ]); |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | rrmdir(app_path("CBPlugins/".$key)); |
| 104 | 104 | |
| 105 | 105 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
| 106 | - }else{ |
|
| 106 | + } else{ |
|
| 107 | 107 | return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
| 108 | 108 | } |
| 109 | - }else { |
|
| 109 | + } else { |
|
| 110 | 110 | return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -118,8 +118,7 @@ discard block |
||
| 118 | 118 | if (( $file != '.' ) && ( $file != '..' )) { |
| 119 | 119 | if ( is_dir($src . '/' . $file) ) { |
| 120 | 120 | $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
| 121 | - } |
|
| 122 | - else { |
|
| 121 | + } else { |
|
| 123 | 122 | copy($src . '/' . $file,$dst . '/' . $file); |
| 124 | 123 | } |
| 125 | 124 | } |
@@ -165,7 +164,9 @@ discard block |
||
| 165 | 164 | fclose($temp); |
| 166 | 165 | |
| 167 | 166 | // Rename |
| 168 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
| 167 | + if(file_exists(app_path("CBPlugins/".$key))) { |
|
| 168 | + rrmdir(app_path("CBPlugins/".$key)); |
|
| 169 | + } |
|
| 169 | 170 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
| 170 | 171 | |
| 171 | 172 | // Read Plugin JSON |
@@ -192,7 +193,7 @@ discard block |
||
| 192 | 193 | } |
| 193 | 194 | } |
| 194 | 195 | |
| 195 | - }else{ |
|
| 196 | + } else{ |
|
| 196 | 197 | return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
| 197 | 198 | } |
| 198 | 199 | } catch (\Exception $e) { |
@@ -31,25 +31,25 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function getIndex() { |
| 33 | 33 | |
| 34 | - if(request("refresh")) { |
|
| 35 | - $this->fetchPluginData(false ); |
|
| 36 | - return cb()->redirectBack("Plugin list has been refreshed!","success"); |
|
| 34 | + if (request("refresh")) { |
|
| 35 | + $this->fetchPluginData(false); |
|
| 36 | + return cb()->redirectBack("Plugin list has been refreshed!", "success"); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $data = []; |
| 40 | 40 | $data['result'] = $this->fetchPluginData(); |
| 41 | - return view($this->view.'.index',$data); |
|
| 41 | + return view($this->view.'.index', $data); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function getUninstall($key) |
| 45 | 45 | { |
| 46 | 46 | $pluginData = $this->fetchPluginData(); |
| 47 | 47 | |
| 48 | - if(isset($pluginData[$key])) { |
|
| 49 | - if(file_exists(app_path("CBPlugins/".$key))) { |
|
| 48 | + if (isset($pluginData[$key])) { |
|
| 49 | + if (file_exists(app_path("CBPlugins/".$key))) { |
|
| 50 | 50 | |
| 51 | - if(isset($pluginData['source']) && $pluginData['source'] == 'composer') { |
|
| 52 | - if(isset($pluginData['package'])) { |
|
| 51 | + if (isset($pluginData['source']) && $pluginData['source'] == 'composer') { |
|
| 52 | + if (isset($pluginData['package'])) { |
|
| 53 | 53 | ComposerHelper::composerRemove($pluginData['package']); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -57,24 +57,24 @@ discard block |
||
| 57 | 57 | rrmdir(app_path("CBPlugins/".$key)); |
| 58 | 58 | |
| 59 | 59 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
| 60 | - }else{ |
|
| 61 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
|
| 60 | + } else { |
|
| 61 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']); |
|
| 62 | 62 | } |
| 63 | - }else { |
|
| 64 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
|
| 63 | + } else { |
|
| 64 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - private function recursiveCopy($src,$dst) { |
|
| 68 | + private function recursiveCopy($src, $dst) { |
|
| 69 | 69 | $dir = opendir($src); |
| 70 | 70 | @mkdir($dst); |
| 71 | - while(false !== ( $file = readdir($dir)) ) { |
|
| 72 | - if (( $file != '.' ) && ( $file != '..' )) { |
|
| 73 | - if ( is_dir($src . '/' . $file) ) { |
|
| 74 | - $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
|
| 71 | + while (false !== ($file = readdir($dir))) { |
|
| 72 | + if (($file != '.') && ($file != '..')) { |
|
| 73 | + if (is_dir($src.'/'.$file)) { |
|
| 74 | + $this->recursiveCopy($src.'/'.$file, $dst.'/'.$file); |
|
| 75 | 75 | } |
| 76 | 76 | else { |
| 77 | - copy($src . '/' . $file,$dst . '/' . $file); |
|
| 77 | + copy($src.'/'.$file, $dst.'/'.$file); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -83,26 +83,26 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | public function getInstall($key) |
| 85 | 85 | { |
| 86 | - ini_set("memory_limit","192M"); |
|
| 86 | + ini_set("memory_limit", "192M"); |
|
| 87 | 87 | set_time_limit(500); |
| 88 | 88 | |
| 89 | 89 | $pluginData = $this->fetchPluginData(); |
| 90 | 90 | |
| 91 | 91 | try { |
| 92 | - if(isset($pluginData[$key])) { |
|
| 92 | + if (isset($pluginData[$key])) { |
|
| 93 | 93 | $plugin = $pluginData[$key]; |
| 94 | 94 | |
| 95 | - if(isset($plugin['source']) && $plugin['source'] == "composer") { |
|
| 95 | + if (isset($plugin['source']) && $plugin['source'] == "composer") { |
|
| 96 | 96 | |
| 97 | - if(isset($plugin['package']) && isset($plugin['service_provider'])) { |
|
| 97 | + if (isset($plugin['package']) && isset($plugin['service_provider'])) { |
|
| 98 | 98 | // Make a composer |
| 99 | 99 | $output = ComposerHelper::composerRequire($plugin['package'], $plugin['service_provider']); |
| 100 | 100 | |
| 101 | 101 | Artisan::call("migrate"); |
| 102 | 102 | |
| 103 | - return response()->json(['status'=>true,'message'=>$output]); |
|
| 103 | + return response()->json(['status'=>true, 'message'=>$output]); |
|
| 104 | 104 | } else { |
| 105 | - return response()->json(['status'=>true,'message'=>'Installation is failed, there is no package and or service provider']); |
|
| 105 | + return response()->json(['status'=>true, 'message'=>'Installation is failed, there is no package and or service provider']); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | } else { |
@@ -121,16 +121,16 @@ discard block |
||
| 121 | 121 | fclose($temp); |
| 122 | 122 | |
| 123 | 123 | // Rename |
| 124 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
| 124 | + if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
| 125 | 125 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
| 126 | 126 | |
| 127 | 127 | // Read Plugin JSON |
| 128 | 128 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$key."/plugin.json")), true); |
| 129 | 129 | |
| 130 | 130 | // Check if has asset |
| 131 | - if($pluginJson && $pluginJson['asset']) { |
|
| 131 | + if ($pluginJson && $pluginJson['asset']) { |
|
| 132 | 132 | // Check destination folder is ready |
| 133 | - if(file_exists(public_path("cb_asset/".$key))) { |
|
| 133 | + if (file_exists(public_path("cb_asset/".$key))) { |
|
| 134 | 134 | rrmdir(public_path("cb_asset/".$key)); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -144,31 +144,31 @@ discard block |
||
| 144 | 144 | //Migrate |
| 145 | 145 | Artisan::call("migrate"); |
| 146 | 146 | |
| 147 | - return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']); |
|
| 147 | + return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']); |
|
| 148 | 148 | |
| 149 | 149 | } else { |
| 150 | - return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
| 150 | + return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - }else{ |
|
| 155 | - return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
|
| 154 | + } else { |
|
| 155 | + return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']); |
|
| 156 | 156 | } |
| 157 | 157 | } catch (\Exception $e) { |
| 158 | - return response()->json(['status'=>false,'message'=>'Something went wrong!']); |
|
| 158 | + return response()->json(['status'=>false, 'message'=>'Something went wrong!']); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | private function fetchPluginData($cache = true) |
| 163 | 163 | { |
| 164 | - if($cache === true && $data = Cache::get("plugin_store_data")) { |
|
| 164 | + if ($cache === true && $data = Cache::get("plugin_store_data")) { |
|
| 165 | 165 | return $data; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $result = []; |
| 169 | 169 | |
| 170 | 170 | try { |
| 171 | - $no_cache = ($cache)?0:1; |
|
| 171 | + $no_cache = ($cache) ? 0 : 1; |
|
| 172 | 172 | $opts = [ |
| 173 | 173 | "http" => [ |
| 174 | 174 | "method" => "GET", |
@@ -181,13 +181,13 @@ discard block |
||
| 181 | 181 | $context = stream_context_create($opts); |
| 182 | 182 | $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context); |
| 183 | 183 | |
| 184 | - if($data) { |
|
| 184 | + if ($data) { |
|
| 185 | 185 | $data = json_decode($data, true); |
| 186 | - if($data['status']==true) { |
|
| 186 | + if ($data['status'] == true) { |
|
| 187 | 187 | |
| 188 | - foreach($data['data'] as $item) { |
|
| 188 | + foreach ($data['data'] as $item) { |
|
| 189 | 189 | $key = $item['key']; |
| 190 | - $result[ $key ] = $item; |
|
| 190 | + $result[$key] = $item; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | $result = collect($result)->sortBy("name")->all(); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public function up() |
| 14 | 14 | { |
| 15 | - Schema::table('users', function (Blueprint $table) { |
|
| 15 | + Schema::table('users', function(Blueprint $table) { |
|
| 16 | 16 | $table->string('photo')->nullable(); |
| 17 | 17 | $table->integer('cb_roles_id'); |
| 18 | 18 | $table->ipAddress("ip_address")->nullable(); |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function down() |
| 30 | 30 | { |
| 31 | - Schema::table('users', function (Blueprint $table) { |
|
| 32 | - $table->dropColumn(["photo","cb_roles_id","ip_address","user_agent","login_at"]); |
|
| 31 | + Schema::table('users', function(Blueprint $table) { |
|
| 32 | + $table->dropColumn(["photo", "cb_roles_id", "ip_address", "user_agent", "login_at"]); |
|
| 33 | 33 | }); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | $process->setInput("Y"); |
| 56 | 56 | $process->setWorkingDirectory(base_path())->run(); |
| 57 | 57 | |
| 58 | - Artisan::call("vendor:publish",["--provider"=>$serviceProvider]); |
|
| 58 | + Artisan::call("vendor:publish", ["--provider"=>$serviceProvider]); |
|
| 59 | 59 | |
| 60 | 60 | return $process->getOutput(); |
| 61 | 61 | } |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | $menu['type'] = request('type'); |
| 56 | 56 | if(request('type') == 'module') { |
| 57 | 57 | $menu['cb_modules_id'] = request('cb_modules_id'); |
| 58 | - }elseif (request('type') == 'url') { |
|
| 58 | + } elseif (request('type') == 'url') { |
|
| 59 | 59 | $menu['path'] = request('url_value'); |
| 60 | - }elseif (request('type') == 'path') { |
|
| 60 | + } elseif (request('type') == 'path') { |
|
| 61 | 61 | $menu['path'] = request('path_value'); |
| 62 | 62 | } elseif (request("type") == "empty") { |
| 63 | 63 | $menu['path'] = "javascript:void(0);"; |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | $menu['type'] = request('type'); |
| 85 | 85 | if(request('type') == 'module') { |
| 86 | 86 | $menu['cb_modules_id'] = request('cb_modules_id'); |
| 87 | - }elseif (request('type') == 'url') { |
|
| 87 | + } elseif (request('type') == 'url') { |
|
| 88 | 88 | $menu['path'] = request('url_value'); |
| 89 | - }elseif (request('type') == 'path') { |
|
| 89 | + } elseif (request('type') == 'path') { |
|
| 90 | 90 | $menu['path'] = request('path_value'); |
| 91 | 91 | } elseif (request("type") == "empty") { |
| 92 | 92 | $menu['path'] = "javascript:void(0);"; |
@@ -25,14 +25,14 @@ 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 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $data = []; |
| 41 | 41 | $data['form_title'] = "Edit Menu"; |
| 42 | 42 | $data['form_url'] = cb()->getDeveloperUrl("menus/edit-save/".$id); |
| 43 | - $data['modules'] = DB::table("cb_modules")->orderBy("name","asc")->get(); |
|
| 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'); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | CacheHelper::forgetGroup("sidebar_menu"); |
| 69 | 69 | |
| 70 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been added!","success"); |
|
| 70 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been added!", "success"); |
|
| 71 | 71 | |
| 72 | 72 | } catch (CBValidationException $e) { |
| 73 | 73 | return cb()->redirectBack($e->getMessage()); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $menu['name'] = request('name'); |
| 83 | 83 | $menu['icon'] = request('icon'); |
| 84 | 84 | $menu['type'] = request('type'); |
| 85 | - if(request('type') == 'module') { |
|
| 85 | + if (request('type') == 'module') { |
|
| 86 | 86 | $menu['cb_modules_id'] = request('cb_modules_id'); |
| 87 | 87 | }elseif (request('type') == 'url') { |
| 88 | 88 | $menu['path'] = request('url_value'); |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | } elseif (request("type") == "empty") { |
| 92 | 92 | $menu['path'] = "javascript:void(0);"; |
| 93 | 93 | } |
| 94 | - DB::table("cb_menus")->where("id",$id)->update($menu); |
|
| 94 | + DB::table("cb_menus")->where("id", $id)->update($menu); |
|
| 95 | 95 | |
| 96 | 96 | CacheHelper::forgetGroup("sidebar_menu"); |
| 97 | 97 | |
| 98 | - return cb()->redirect(route("DeveloperMenusControllerGetIndex"),"The menu has been saved!","success"); |
|
| 98 | + return cb()->redirect(route("DeveloperMenusControllerGetIndex"), "The menu has been saved!", "success"); |
|
| 99 | 99 | |
| 100 | 100 | } catch (CBValidationException $e) { |
| 101 | 101 | return cb()->redirectBack($e->getMessage()); |
@@ -108,20 +108,20 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $menus = request('menus'); |
| 110 | 110 | $menus = json_decode($menus, true); |
| 111 | - if($menus) { |
|
| 111 | + if ($menus) { |
|
| 112 | 112 | $menus = $menus[0]; |
| 113 | - if($menus) { |
|
| 114 | - foreach($menus as $i=>$menu) { |
|
| 113 | + if ($menus) { |
|
| 114 | + foreach ($menus as $i=>$menu) { |
|
| 115 | 115 | $id = $menu['id']; |
| 116 | - cb()->update("cb_menus",$id,["sort_number"=>$i,'parent_cb_menus_id'=>null]); |
|
| 117 | - if($menu['children'][0]) { |
|
| 118 | - foreach($menu['children'][0] as $ii=>$sub) { |
|
| 116 | + cb()->update("cb_menus", $id, ["sort_number"=>$i, 'parent_cb_menus_id'=>null]); |
|
| 117 | + if ($menu['children'][0]) { |
|
| 118 | + foreach ($menu['children'][0] as $ii=>$sub) { |
|
| 119 | 119 | $id = $sub['id']; |
| 120 | - cb()->update("cb_menus",$id,["sort_number"=>$ii,"parent_cb_menus_id"=>$menu['id']]); |
|
| 121 | - if($sub['children'][0]) { |
|
| 122 | - foreach($sub['children'][0] as $iii=>$subsub) { |
|
| 120 | + cb()->update("cb_menus", $id, ["sort_number"=>$ii, "parent_cb_menus_id"=>$menu['id']]); |
|
| 121 | + if ($sub['children'][0]) { |
|
| 122 | + foreach ($sub['children'][0] as $iii=>$subsub) { |
|
| 123 | 123 | $id = $subsub['id']; |
| 124 | - cb()->update("cb_menus",$id,["sort_number"=>$iii,"parent_cb_menus_id"=>$sub['id']]); |
|
| 124 | + cb()->update("cb_menus", $id, ["sort_number"=>$iii, "parent_cb_menus_id"=>$sub['id']]); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -132,20 +132,20 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | CacheHelper::forgetGroup("sidebar_menu"); |
| 134 | 134 | |
| 135 | - return response()->json(['api_status'=>1,'api_message'=>'success']); |
|
| 135 | + return response()->json(['api_status'=>1, 'api_message'=>'success']); |
|
| 136 | 136 | |
| 137 | 137 | } catch (CBValidationException $e) { |
| 138 | - return response()->json(['api_status'=>0,'api_message'=>$e->getMessage()]); |
|
| 138 | + return response()->json(['api_status'=>0, 'api_message'=>$e->getMessage()]); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public function getDelete($id) { |
| 143 | - DB::table("cb_menus")->where("id",$id)->delete(); |
|
| 143 | + DB::table("cb_menus")->where("id", $id)->delete(); |
|
| 144 | 144 | DB::table("cb_role_privileges")->where("cb_menus_id", $id)->delete(); |
| 145 | 145 | |
| 146 | 146 | CacheHelper::forgetGroup("sidebar_menu"); |
| 147 | 147 | |
| 148 | - return cb()->redirectBack("The menu has been deleted!","success"); |
|
| 148 | + return cb()->redirectBack("The menu has been deleted!", "success"); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | } |
| 152 | 152 | \ No newline at end of file |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | // Register views |
| 26 | 26 | $this->loadViewsFrom(__DIR__.'/views', 'crudbooster'); |
| 27 | 27 | $this->loadViewsFrom(__DIR__.'/types', 'types'); |
| 28 | - $this->loadTranslationsFrom(__DIR__."/localization","cb"); |
|
| 28 | + $this->loadTranslationsFrom(__DIR__."/localization", "cb"); |
|
| 29 | 29 | |
| 30 | 30 | // Publish the files |
| 31 | - $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')],'cb_config'); |
|
| 32 | - $this->publishes([__DIR__.'/database' => base_path('database')],'cb_migration'); |
|
| 33 | - $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')],'cb_hook'); |
|
| 34 | - $this->publishes([__DIR__ . '/assets' =>public_path('cb_asset')],'cb_asset'); |
|
| 31 | + $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')], 'cb_config'); |
|
| 32 | + $this->publishes([__DIR__.'/database' => base_path('database')], 'cb_migration'); |
|
| 33 | + $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')], 'cb_hook'); |
|
| 34 | + $this->publishes([__DIR__.'/assets' =>public_path('cb_asset')], 'cb_asset'); |
|
| 35 | 35 | |
| 36 | 36 | // Override Local FileSystem |
| 37 | 37 | Config::set("filesystems.disks.local.root", cbConfig("LOCAL_FILESYSTEM_PATH", public_path("storage"))); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | require __DIR__.'/helpers/Helper.php'; |
| 54 | 54 | |
| 55 | 55 | // Singletons |
| 56 | - $this->app->singleton('crudbooster', function () |
|
| 56 | + $this->app->singleton('crudbooster', function() |
|
| 57 | 57 | { |
| 58 | 58 | return true; |
| 59 | 59 | }); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Merging configuration |
| 79 | - $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php','crudbooster'); |
|
| 79 | + $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster'); |
|
| 80 | 80 | |
| 81 | 81 | // Register additional library |
| 82 | 82 | $this->app->register('Intervention\Image\ImageServiceProvider'); |
@@ -84,17 +84,17 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | private function registerPlugin() |
| 86 | 86 | { |
| 87 | - if(file_exists(app_path("CBPlugins"))) { |
|
| 87 | + if (file_exists(app_path("CBPlugins"))) { |
|
| 88 | 88 | $views = scandir(app_path("CBPlugins")); |
| 89 | - foreach($views as $view) { |
|
| 90 | - if($view != "." && $view != "..") { |
|
| 89 | + foreach ($views as $view) { |
|
| 90 | + if ($view != "." && $view != "..") { |
|
| 91 | 91 | $basename = basename($view); |
| 92 | 92 | |
| 93 | 93 | // register migrations |
| 94 | 94 | $this->loadMigrationsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Migrations")); |
| 95 | 95 | |
| 96 | 96 | // register view |
| 97 | - $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"),$basename); |
|
| 97 | + $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"), $basename); |
|
| 98 | 98 | |
| 99 | 99 | // register route |
| 100 | 100 | require app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Routes".DIRECTORY_SEPARATOR."Route.php"); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | private function registerTypeRoutes() { |
| 109 | 109 | $routes = rglob(__DIR__.DIRECTORY_SEPARATOR."types".DIRECTORY_SEPARATOR."Route.php"); |
| 110 | - foreach($routes as $route) { |
|
| 110 | + foreach ($routes as $route) { |
|
| 111 | 111 | require $route; |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -26,17 +26,17 @@ discard block |
||
| 26 | 26 | try { |
| 27 | 27 | $routeArray = request()->route()->getAction(); |
| 28 | 28 | $this->controller = class_basename($routeArray['controller']); |
| 29 | - $this->controller = strtok($this->controller,"@"); |
|
| 29 | + $this->controller = strtok($this->controller, "@"); |
|
| 30 | 30 | |
| 31 | 31 | $className = "\\".$routeArray["namespace"]."\\".$this->controller; |
| 32 | - if(class_exists($className)) { |
|
| 33 | - $this->module = cb()->find("cb_modules",["controller"=>$this->controller]); |
|
| 34 | - if($this->module) { |
|
| 32 | + if (class_exists($className)) { |
|
| 33 | + $this->module = cb()->find("cb_modules", ["controller"=>$this->controller]); |
|
| 34 | + if ($this->module) { |
|
| 35 | 35 | $this->controller_class = new $className(); |
| 36 | - $this->menu = cb()->find("cb_menus",["cb_modules_id"=>$this->module->id]); |
|
| 37 | - $this->menu = (!$this->menu)?cb()->find("cb_menus",["type"=>"path","path"=>request()->segment(2)]):$this->menu; |
|
| 38 | - if($this->menu) { |
|
| 39 | - $this->privilege = cb()->find("cb_role_privileges",[ |
|
| 36 | + $this->menu = cb()->find("cb_menus", ["cb_modules_id"=>$this->module->id]); |
|
| 37 | + $this->menu = (!$this->menu) ?cb()->find("cb_menus", ["type"=>"path", "path"=>request()->segment(2)]) : $this->menu; |
|
| 38 | + if ($this->menu) { |
|
| 39 | + $this->privilege = cb()->find("cb_role_privileges", [ |
|
| 40 | 40 | "cb_menus_id"=>$this->menu->id, |
| 41 | 41 | "cb_roles_id"=>cb()->session()->roleId() |
| 42 | 42 | ]); |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function getData($key) { |
| 60 | - if($this->controller_class) { |
|
| 60 | + if ($this->controller_class) { |
|
| 61 | 61 | $value = $this->controller_class->getData($key); |
| 62 | - if(isset($value)) { |
|
| 62 | + if (isset($value)) { |
|
| 63 | 63 | return $value; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -70,128 +70,128 @@ discard block |
||
| 70 | 70 | * @return CBController |
| 71 | 71 | */ |
| 72 | 72 | public function getController() { |
| 73 | - return ($this->controller_class)?$this->controller_class:null; |
|
| 73 | + return ($this->controller_class) ? $this->controller_class : null; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function getPageTitle() |
| 77 | 77 | { |
| 78 | - return ($this->controller_class)?$this->controller_class->getData("page_title")?:cb()->getAppName():null; |
|
| 78 | + return ($this->controller_class) ? $this->controller_class->getData("page_title") ?: cb()->getAppName() : null; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public function getTable() |
| 82 | 82 | { |
| 83 | - return ($this->controller_class)?$this->controller_class->getData("table"):null; |
|
| 83 | + return ($this->controller_class) ? $this->controller_class->getData("table") : null; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function getPageIcon() |
| 87 | 87 | { |
| 88 | - return ($this->controller_class)?$this->controller_class->getData('page_icon')?:"fa fa-bars":null; |
|
| 88 | + return ($this->controller_class) ? $this->controller_class->getData('page_icon') ?: "fa fa-bars" : null; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function canBrowse() { |
| 92 | - if($this->privilege) { |
|
| 93 | - if($this->privilege->can_browse) return true; |
|
| 92 | + if ($this->privilege) { |
|
| 93 | + if ($this->privilege->can_browse) return true; |
|
| 94 | 94 | else return false; |
| 95 | - }else{ |
|
| 95 | + } else { |
|
| 96 | 96 | return true; |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | public function canCreate() { |
| 101 | - if($this->privilege) { |
|
| 102 | - if($this->privilege->can_create) return true; |
|
| 101 | + if ($this->privilege) { |
|
| 102 | + if ($this->privilege->can_create) return true; |
|
| 103 | 103 | else return false; |
| 104 | - }else{ |
|
| 104 | + } else { |
|
| 105 | 105 | return true; |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | public function canRead() { |
| 110 | - if($this->privilege) { |
|
| 111 | - if($this->privilege->can_read) return true; |
|
| 110 | + if ($this->privilege) { |
|
| 111 | + if ($this->privilege->can_read) return true; |
|
| 112 | 112 | else return false; |
| 113 | - }else{ |
|
| 113 | + } else { |
|
| 114 | 114 | return true; |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function canUpdate() { |
| 119 | - if($this->privilege) { |
|
| 120 | - if($this->privilege->can_update) return true; |
|
| 119 | + if ($this->privilege) { |
|
| 120 | + if ($this->privilege->can_update) return true; |
|
| 121 | 121 | else return false; |
| 122 | - }else{ |
|
| 122 | + } else { |
|
| 123 | 123 | return true; |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | public function canDelete() { |
| 128 | - if($this->privilege) { |
|
| 129 | - if($this->privilege->can_delete) return true; |
|
| 128 | + if ($this->privilege) { |
|
| 129 | + if ($this->privilege->can_delete) return true; |
|
| 130 | 130 | else return false; |
| 131 | - }else{ |
|
| 131 | + } else { |
|
| 132 | 132 | return true; |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | public function addURL() |
| 137 | 137 | { |
| 138 | - if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
| 138 | + if ($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
|
| 139 | 139 | return action($this->controller.'@getAdd'); |
| 140 | - }else{ |
|
| 140 | + } else { |
|
| 141 | 141 | return null; |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | public function addSaveURL() |
| 146 | 146 | { |
| 147 | - if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
| 147 | + if ($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
|
| 148 | 148 | return action($this->controller.'@postAddSave'); |
| 149 | - }else{ |
|
| 149 | + } else { |
|
| 150 | 150 | return null; |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | public function editURL($id = null) |
| 155 | 155 | { |
| 156 | - if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
| 156 | + if ($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
|
| 157 | 157 | return action($this->controller.'@getEdit')."/".$id; |
| 158 | - }else{ |
|
| 158 | + } else { |
|
| 159 | 159 | return null; |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | public function editSaveURL($id = null) |
| 164 | 164 | { |
| 165 | - if(method_exists($this->controller_class, 'postEditSave')) { |
|
| 165 | + if (method_exists($this->controller_class, 'postEditSave')) { |
|
| 166 | 166 | return action($this->controller.'@postEditSave')."/".$id; |
| 167 | - }else{ |
|
| 167 | + } else { |
|
| 168 | 168 | return null; |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - public function detailURL($id=null) |
|
| 172 | + public function detailURL($id = null) |
|
| 173 | 173 | { |
| 174 | - if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
| 174 | + if ($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
|
| 175 | 175 | return action($this->controller.'@getDetail')."/".$id; |
| 176 | - }else{ |
|
| 176 | + } else { |
|
| 177 | 177 | return null; |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public function deleteURL($id=null) |
|
| 181 | + public function deleteURL($id = null) |
|
| 182 | 182 | { |
| 183 | - if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
| 183 | + if ($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
|
| 184 | 184 | return action($this->controller.'@getDelete')."/".$id; |
| 185 | - }else{ |
|
| 185 | + } else { |
|
| 186 | 186 | return null; |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | public function url($path = null) |
| 191 | 191 | { |
| 192 | - if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
| 193 | - return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
|
| 194 | - }else{ |
|
| 192 | + if ($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
|
| 193 | + return trim(action($this->controller.'@getIndex').'/'.$path, '/'); |
|
| 194 | + } else { |
|
| 195 | 195 | return null; |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -90,45 +90,60 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | public function canBrowse() { |
| 92 | 92 | if($this->privilege) { |
| 93 | - if($this->privilege->can_browse) return true; |
|
| 94 | - else return false; |
|
| 95 | - }else{ |
|
| 93 | + if($this->privilege->can_browse) { |
|
| 94 | + return true; |
|
| 95 | + } else { |
|
| 96 | + return false; |
|
| 97 | + } |
|
| 98 | + } else{ |
|
| 96 | 99 | return true; |
| 97 | 100 | } |
| 98 | 101 | } |
| 99 | 102 | |
| 100 | 103 | public function canCreate() { |
| 101 | 104 | if($this->privilege) { |
| 102 | - if($this->privilege->can_create) return true; |
|
| 103 | - else return false; |
|
| 104 | - }else{ |
|
| 105 | + if($this->privilege->can_create) { |
|
| 106 | + return true; |
|
| 107 | + } else { |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 110 | + } else{ |
|
| 105 | 111 | return true; |
| 106 | 112 | } |
| 107 | 113 | } |
| 108 | 114 | |
| 109 | 115 | public function canRead() { |
| 110 | 116 | if($this->privilege) { |
| 111 | - if($this->privilege->can_read) return true; |
|
| 112 | - else return false; |
|
| 113 | - }else{ |
|
| 117 | + if($this->privilege->can_read) { |
|
| 118 | + return true; |
|
| 119 | + } else { |
|
| 120 | + return false; |
|
| 121 | + } |
|
| 122 | + } else{ |
|
| 114 | 123 | return true; |
| 115 | 124 | } |
| 116 | 125 | } |
| 117 | 126 | |
| 118 | 127 | public function canUpdate() { |
| 119 | 128 | if($this->privilege) { |
| 120 | - if($this->privilege->can_update) return true; |
|
| 121 | - else return false; |
|
| 122 | - }else{ |
|
| 129 | + if($this->privilege->can_update) { |
|
| 130 | + return true; |
|
| 131 | + } else { |
|
| 132 | + return false; |
|
| 133 | + } |
|
| 134 | + } else{ |
|
| 123 | 135 | return true; |
| 124 | 136 | } |
| 125 | 137 | } |
| 126 | 138 | |
| 127 | 139 | public function canDelete() { |
| 128 | 140 | if($this->privilege) { |
| 129 | - if($this->privilege->can_delete) return true; |
|
| 130 | - else return false; |
|
| 131 | - }else{ |
|
| 141 | + if($this->privilege->can_delete) { |
|
| 142 | + return true; |
|
| 143 | + } else { |
|
| 144 | + return false; |
|
| 145 | + } |
|
| 146 | + } else{ |
|
| 132 | 147 | return true; |
| 133 | 148 | } |
| 134 | 149 | } |
@@ -137,7 +152,7 @@ discard block |
||
| 137 | 152 | { |
| 138 | 153 | if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
| 139 | 154 | return action($this->controller.'@getAdd'); |
| 140 | - }else{ |
|
| 155 | + } else{ |
|
| 141 | 156 | return null; |
| 142 | 157 | } |
| 143 | 158 | } |
@@ -146,7 +161,7 @@ discard block |
||
| 146 | 161 | { |
| 147 | 162 | if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
| 148 | 163 | return action($this->controller.'@postAddSave'); |
| 149 | - }else{ |
|
| 164 | + } else{ |
|
| 150 | 165 | return null; |
| 151 | 166 | } |
| 152 | 167 | } |
@@ -155,7 +170,7 @@ discard block |
||
| 155 | 170 | { |
| 156 | 171 | if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
| 157 | 172 | return action($this->controller.'@getEdit')."/".$id; |
| 158 | - }else{ |
|
| 173 | + } else{ |
|
| 159 | 174 | return null; |
| 160 | 175 | } |
| 161 | 176 | } |
@@ -164,7 +179,7 @@ discard block |
||
| 164 | 179 | { |
| 165 | 180 | if(method_exists($this->controller_class, 'postEditSave')) { |
| 166 | 181 | return action($this->controller.'@postEditSave')."/".$id; |
| 167 | - }else{ |
|
| 182 | + } else{ |
|
| 168 | 183 | return null; |
| 169 | 184 | } |
| 170 | 185 | } |
@@ -173,7 +188,7 @@ discard block |
||
| 173 | 188 | { |
| 174 | 189 | if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
| 175 | 190 | return action($this->controller.'@getDetail')."/".$id; |
| 176 | - }else{ |
|
| 191 | + } else{ |
|
| 177 | 192 | return null; |
| 178 | 193 | } |
| 179 | 194 | } |
@@ -182,7 +197,7 @@ discard block |
||
| 182 | 197 | { |
| 183 | 198 | if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
| 184 | 199 | return action($this->controller.'@getDelete')."/".$id; |
| 185 | - }else{ |
|
| 200 | + } else{ |
|
| 186 | 201 | return null; |
| 187 | 202 | } |
| 188 | 203 | } |
@@ -191,7 +206,7 @@ discard block |
||
| 191 | 206 | { |
| 192 | 207 | if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
| 193 | 208 | return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
| 194 | - }else{ |
|
| 209 | + } else{ |
|
| 195 | 210 | return null; |
| 196 | 211 | } |
| 197 | 212 | } |