@@ -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'); |
@@ -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 | } |
@@ -31,14 +31,14 @@ 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 postLoginAccount() { |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | ]); |
54 | 54 | $response = $curl->send(); |
55 | 55 | |
56 | - if($respArray = json_decode($response, true)) { |
|
57 | - if($respArray['status'] && isset($respArray['token'])) { |
|
56 | + if ($respArray = json_decode($response, true)) { |
|
57 | + if ($respArray['status'] && isset($respArray['token'])) { |
|
58 | 58 | session(['account_token'=>$respArray['token']]); |
59 | 59 | } |
60 | - return response()->make($response,200,["Content-Type"=>"application/json"]); |
|
60 | + return response()->make($response, 200, ["Content-Type"=>"application/json"]); |
|
61 | 61 | } else { |
62 | - return response()->json(['status'=>false,'message'=>'failed']); |
|
62 | + return response()->json(['status'=>false, 'message'=>'failed']); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | ]); |
77 | 77 | $response = $curl->send(); |
78 | 78 | |
79 | - if($respArray = json_decode($response, true)) { |
|
80 | - if($respArray['status']) { |
|
79 | + if ($respArray = json_decode($response, true)) { |
|
80 | + if ($respArray['status']) { |
|
81 | 81 | $form = base64_decode($respArray['payment']); |
82 | - return response()->json(['status'=>true,'form'=>$form]); |
|
82 | + return response()->json(['status'=>true, 'form'=>$form]); |
|
83 | 83 | } else { |
84 | 84 | return response()->json($respArray); |
85 | 85 | } |
86 | 86 | } else { |
87 | - return response()->json(['status'=>false,'message'=>'failed','raw'=>$response]); |
|
87 | + return response()->json(['status'=>false, 'message'=>'failed', 'raw'=>$response]); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | { |
93 | 93 | $pluginData = $this->fetchPluginData(); |
94 | 94 | |
95 | - if(isset($pluginData[$key])) { |
|
96 | - if(file_exists(app_path("CBPlugins/".$key))) { |
|
95 | + if (isset($pluginData[$key])) { |
|
96 | + if (file_exists(app_path("CBPlugins/".$key))) { |
|
97 | 97 | |
98 | - if(isset($pluginData['source']) && $pluginData['source'] == 'composer') { |
|
99 | - if(isset($pluginData['package'])) { |
|
98 | + if (isset($pluginData['source']) && $pluginData['source'] == 'composer') { |
|
99 | + if (isset($pluginData['package'])) { |
|
100 | 100 | ComposerHelper::composerRemove($pluginData['package']); |
101 | 101 | } |
102 | 102 | } |
@@ -104,24 +104,24 @@ discard block |
||
104 | 104 | rrmdir(app_path("CBPlugins/".$key)); |
105 | 105 | |
106 | 106 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
107 | - }else{ |
|
108 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
|
107 | + } else { |
|
108 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']); |
|
109 | 109 | } |
110 | - }else { |
|
111 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
|
110 | + } else { |
|
111 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - private function recursiveCopy($src,$dst) { |
|
115 | + private function recursiveCopy($src, $dst) { |
|
116 | 116 | $dir = opendir($src); |
117 | 117 | @mkdir($dst); |
118 | - while(false !== ( $file = readdir($dir)) ) { |
|
119 | - if (( $file != '.' ) && ( $file != '..' )) { |
|
120 | - if ( is_dir($src . '/' . $file) ) { |
|
121 | - $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
|
118 | + while (false !== ($file = readdir($dir))) { |
|
119 | + if (($file != '.') && ($file != '..')) { |
|
120 | + if (is_dir($src.'/'.$file)) { |
|
121 | + $this->recursiveCopy($src.'/'.$file, $dst.'/'.$file); |
|
122 | 122 | } |
123 | 123 | else { |
124 | - copy($src . '/' . $file,$dst . '/' . $file); |
|
124 | + copy($src.'/'.$file, $dst.'/'.$file); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
@@ -130,26 +130,26 @@ discard block |
||
130 | 130 | |
131 | 131 | public function getInstall($key) |
132 | 132 | { |
133 | - ini_set("memory_limit","192M"); |
|
133 | + ini_set("memory_limit", "192M"); |
|
134 | 134 | set_time_limit(500); |
135 | 135 | |
136 | 136 | $pluginData = $this->fetchPluginData(); |
137 | 137 | |
138 | 138 | try { |
139 | - if(isset($pluginData[$key])) { |
|
139 | + if (isset($pluginData[$key])) { |
|
140 | 140 | $plugin = $pluginData[$key]; |
141 | 141 | |
142 | - if(isset($plugin['source']) && $plugin['source'] == "composer") { |
|
142 | + if (isset($plugin['source']) && $plugin['source'] == "composer") { |
|
143 | 143 | |
144 | - if(isset($plugin['package']) && isset($plugin['service_provider'])) { |
|
144 | + if (isset($plugin['package']) && isset($plugin['service_provider'])) { |
|
145 | 145 | // Make a composer |
146 | 146 | $output = ComposerHelper::composerRequire($plugin['package'], $plugin['service_provider']); |
147 | 147 | |
148 | 148 | Artisan::call("migrate"); |
149 | 149 | |
150 | - return response()->json(['status'=>true,'message'=>$output]); |
|
150 | + return response()->json(['status'=>true, 'message'=>$output]); |
|
151 | 151 | } else { |
152 | - return response()->json(['status'=>true,'message'=>'Installation is failed, there is no package and or service provider']); |
|
152 | + return response()->json(['status'=>true, 'message'=>'Installation is failed, there is no package and or service provider']); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | } else { |
@@ -168,16 +168,16 @@ discard block |
||
168 | 168 | fclose($temp); |
169 | 169 | |
170 | 170 | // Rename |
171 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
171 | + if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
172 | 172 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
173 | 173 | |
174 | 174 | // Read Plugin JSON |
175 | 175 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$key."/plugin.json")), true); |
176 | 176 | |
177 | 177 | // Check if has asset |
178 | - if($pluginJson && $pluginJson['asset']) { |
|
178 | + if ($pluginJson && $pluginJson['asset']) { |
|
179 | 179 | // Check destination folder is ready |
180 | - if(file_exists(public_path("cb_asset/".$key))) { |
|
180 | + if (file_exists(public_path("cb_asset/".$key))) { |
|
181 | 181 | rrmdir(public_path("cb_asset/".$key)); |
182 | 182 | } |
183 | 183 | |
@@ -191,31 +191,31 @@ discard block |
||
191 | 191 | //Migrate |
192 | 192 | Artisan::call("migrate"); |
193 | 193 | |
194 | - return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']); |
|
194 | + return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']); |
|
195 | 195 | |
196 | 196 | } else { |
197 | - return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
197 | + return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - }else{ |
|
202 | - return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
|
201 | + } else { |
|
202 | + return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']); |
|
203 | 203 | } |
204 | 204 | } catch (\Exception $e) { |
205 | - return response()->json(['status'=>false,'message'=>'Something went wrong!']); |
|
205 | + return response()->json(['status'=>false, 'message'=>'Something went wrong!']); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | 209 | private function fetchPluginData($cache = true) |
210 | 210 | { |
211 | - if($cache === true && $data = Cache::get("plugin_store_data")) { |
|
211 | + if ($cache === true && $data = Cache::get("plugin_store_data")) { |
|
212 | 212 | return $data; |
213 | 213 | } |
214 | 214 | |
215 | 215 | $result = []; |
216 | 216 | |
217 | 217 | try { |
218 | - $no_cache = ($cache)?0:1; |
|
218 | + $no_cache = ($cache) ? 0 : 1; |
|
219 | 219 | $opts = [ |
220 | 220 | "http" => [ |
221 | 221 | "method" => "GET", |
@@ -224,17 +224,17 @@ discard block |
||
224 | 224 | "No-Cache: ".$no_cache |
225 | 225 | ] |
226 | 226 | ]; |
227 | - Log::debug("Headers: ".print_r($opts,true)); |
|
227 | + Log::debug("Headers: ".print_r($opts, true)); |
|
228 | 228 | $context = stream_context_create($opts); |
229 | 229 | $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context); |
230 | 230 | Log::debug("Plugin API : ".$data); |
231 | - if($data) { |
|
231 | + if ($data) { |
|
232 | 232 | $data = json_decode($data, true); |
233 | - if($data['status']==true) { |
|
233 | + if ($data['status'] == true) { |
|
234 | 234 | |
235 | - foreach($data['data'] as $item) { |
|
235 | + foreach ($data['data'] as $item) { |
|
236 | 236 | $key = $item['key']; |
237 | - $result[ $key ] = $item; |
|
237 | + $result[$key] = $item; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | $result = collect($result)->sortBy("name")->all(); |