@@ -1,61 +1,61 @@ 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 | - cb()->routeGet("login-verification","AdminAuthController@getLoginVerification"); |
|
45 | - cb()->routePost("submit-login-verification","AdminAuthController@postSubmitLoginVerification"); |
|
44 | + cb()->routeGet("login-verification", "AdminAuthController@getLoginVerification"); |
|
45 | + cb()->routePost("submit-login-verification", "AdminAuthController@postSubmitLoginVerification"); |
|
46 | 46 | } |
47 | 47 | |
48 | - if(getSetting("enable_forget")) { |
|
49 | - cb()->routePost("forget","AdminAuthController@postForget"); |
|
48 | + if (getSetting("enable_forget")) { |
|
49 | + cb()->routePost("forget", "AdminAuthController@postForget"); |
|
50 | 50 | } |
51 | 51 | |
52 | - if(getSetting("enable_register")) { |
|
53 | - cb()->routePost("register","AdminAuthController@postRegister"); |
|
52 | + if (getSetting("enable_register")) { |
|
53 | + cb()->routePost("register", "AdminAuthController@postRegister"); |
|
54 | 54 | } |
55 | 55 | }); |
56 | 56 | |
57 | 57 | // Routing package controllers |
58 | -cb()->routeGroupBackend(function () { |
|
58 | +cb()->routeGroupBackend(function() { |
|
59 | 59 | cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController'); |
60 | 60 | }); |
61 | 61 | |
@@ -64,24 +64,24 @@ discard block |
||
64 | 64 | 'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class], |
65 | 65 | 'prefix' => cb()->getAdminPath(), |
66 | 66 | 'namespace' => 'App\Http\Controllers', |
67 | -], function () { |
|
67 | +], function() { |
|
68 | 68 | |
69 | 69 | if (Request::is(cb()->getAdminPath())) { |
70 | - if($dashboard = getSetting("dashboard_controller")) { |
|
70 | + if ($dashboard = getSetting("dashboard_controller")) { |
|
71 | 71 | cb()->routeGet("/", $dashboard."@getIndex"); |
72 | - }else{ |
|
72 | + } else { |
|
73 | 73 | cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | $controllers = glob(app_path('Http/Controllers/Admin*Controller.php')); |
78 | 78 | |
79 | - foreach($controllers as $controller) { |
|
79 | + foreach ($controllers as $controller) { |
|
80 | 80 | $controllerName = basename($controller); |
81 | - $controllerName = rtrim($controllerName,".php"); |
|
81 | + $controllerName = rtrim($controllerName, ".php"); |
|
82 | 82 | $className = '\App\Http\Controllers\\'.$controllerName; |
83 | 83 | $controllerClass = new $className(); |
84 | - if(method_exists($controllerClass, 'cbInit')) { |
|
84 | + if (method_exists($controllerClass, 'cbInit')) { |
|
85 | 85 | cb()->routeController($controllerClass->getData('permalink'), $controllerName); |
86 | 86 | } |
87 | 87 | } |
@@ -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 | } |
@@ -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 | } |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | public function getIndex() { |
33 | 33 | $data = []; |
34 | 34 | $data['result'] = DB::table("cb_modules")->get(); |
35 | - return view($this->view.'.index',$data); |
|
35 | + return view($this->view.'.index', $data); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getAdd() { |
39 | 39 | $data = []; |
40 | 40 | $data['tables'] = cb()->listAllTable(); |
41 | - $data['module'] = (request('modules_id'))?cb()->find("cb_modules", request("modules_id")):null; |
|
41 | + $data['module'] = (request('modules_id')) ?cb()->find("cb_modules", request("modules_id")) : null; |
|
42 | 42 | return view($this->view.'.add', $data); |
43 | 43 | } |
44 | 44 | |
@@ -51,17 +51,17 @@ discard block |
||
51 | 51 | $data = cb()->listAllColumns($table); |
52 | 52 | $pk = cb()->findPrimaryKey($table); |
53 | 53 | $result = []; |
54 | - foreach($data as $item) { |
|
54 | + foreach ($data as $item) { |
|
55 | 55 | |
56 | - if(Str::contains(strtolower($item),["title","name","label"])) { |
|
56 | + if (Str::contains(strtolower($item), ["title", "name", "label"])) { |
|
57 | 57 | $display = true; |
58 | - }else{ |
|
58 | + } else { |
|
59 | 59 | $display = false; |
60 | 60 | } |
61 | 61 | |
62 | 62 | $result[] = [ |
63 | 63 | "column"=>$item, |
64 | - "primary_key"=>($pk==$item)?true:false, |
|
64 | + "primary_key"=>($pk == $item) ?true:false, |
|
65 | 65 | "display"=>$display |
66 | 66 | ]; |
67 | 67 | } |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | |
71 | 71 | public function getColumns($table) |
72 | 72 | { |
73 | - if(request("modules_id")) { |
|
74 | - $module = cb()->find("cb_modules",request("modules_id")); |
|
75 | - if($module->last_column_build) { |
|
73 | + if (request("modules_id")) { |
|
74 | + $module = cb()->find("cb_modules", request("modules_id")); |
|
75 | + if ($module->last_column_build) { |
|
76 | 76 | return response()->json(json_decode($module->last_column_build)); |
77 | 77 | } |
78 | 78 | } |
@@ -80,56 +80,56 @@ discard block |
||
80 | 80 | $columns = cb()->listAllColumns($table); |
81 | 81 | $pk = cb()->findPrimaryKey($table); |
82 | 82 | $result = []; |
83 | - foreach($columns as $column) { |
|
84 | - if($column != $pk) { |
|
83 | + foreach ($columns as $column) { |
|
84 | + if ($column != $pk) { |
|
85 | 85 | |
86 | 86 | // Skip Column |
87 | - if($column == 'deleted_at') continue; |
|
87 | + if ($column == 'deleted_at') continue; |
|
88 | 88 | |
89 | 89 | // Check if any relation table candidate |
90 | 90 | $optionTable = ""; |
91 | - if(Str::substr(strtolower($column),-3,3) == "_id") { |
|
92 | - $relationTable = Str::substr($column,0,-3); |
|
93 | - if(Schema::hasTable($relationTable)) { |
|
91 | + if (Str::substr(strtolower($column), -3, 3) == "_id") { |
|
92 | + $relationTable = Str::substr($column, 0, -3); |
|
93 | + if (Schema::hasTable($relationTable)) { |
|
94 | 94 | $optionTable = $relationTable; |
95 | 95 | } |
96 | - }elseif (Str::substr(strtolower($column),0,3) == "id_") { |
|
97 | - $relationTable = Str::substr($column,3); |
|
98 | - if(Schema::hasTable($relationTable)) { |
|
96 | + }elseif (Str::substr(strtolower($column), 0, 3) == "id_") { |
|
97 | + $relationTable = Str::substr($column, 3); |
|
98 | + if (Schema::hasTable($relationTable)) { |
|
99 | 99 | $optionTable = $relationTable; |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - $label = trim(Str::title(str_replace(["id_","_id","_"]," ",$column))); |
|
103 | + $label = trim(Str::title(str_replace(["id_", "_id", "_"], " ", $column))); |
|
104 | 104 | $label = Str::singular($label); |
105 | 105 | $type = "text"; |
106 | 106 | |
107 | - if(Str::contains(strtolower($label),["photo","image","picture","gambar"])) { |
|
107 | + if (Str::contains(strtolower($label), ["photo", "image", "picture", "gambar"])) { |
|
108 | 108 | $type = "image"; |
109 | - }elseif (Str::contains(strtolower($label),["email","mail"])) { |
|
109 | + }elseif (Str::contains(strtolower($label), ["email", "mail"])) { |
|
110 | 110 | $type = "email"; |
111 | - }elseif (Str::contains(strtolower($label),["description","content","detail"])) { |
|
112 | - $type = "wysiwyg"; |
|
113 | - }elseif (Str::contains(strtolower($label),["price","money","grand_total","tax"])) { |
|
111 | + }elseif (Str::contains(strtolower($label), ["description", "content", "detail"])) { |
|
112 | + $type = "wysiwyg"; |
|
113 | + }elseif (Str::contains(strtolower($label), ["price", "money", "grand_total", "tax"])) { |
|
114 | 114 | $type = "money"; |
115 | - }elseif (Str::contains(strtolower($label),["quantity","qty","total","phone","telp"])) { |
|
115 | + }elseif (Str::contains(strtolower($label), ["quantity", "qty", "total", "phone", "telp"])) { |
|
116 | 116 | $type = "number"; |
117 | - }elseif (Str::contains(strtolower($label),["date"])) { |
|
117 | + }elseif (Str::contains(strtolower($label), ["date"])) { |
|
118 | 118 | $type = "date"; |
119 | 119 | } |
120 | 120 | |
121 | - if (Str::substr(strtolower($column),-3,3) == "_id") { |
|
121 | + if (Str::substr(strtolower($column), -3, 3) == "_id") { |
|
122 | 122 | $type = "select_table"; |
123 | 123 | } elseif (Str::substr($column, -3, 3) == "_at") { |
124 | 124 | $type = "datetime"; |
125 | - } elseif (Str::substr($column,0, 3) == "id_") { |
|
125 | + } elseif (Str::substr($column, 0, 3) == "id_") { |
|
126 | 126 | $type = "select_table"; |
127 | 127 | } |
128 | 128 | |
129 | 129 | $columnAdd = "on"; |
130 | 130 | $columnEdit = "on"; |
131 | 131 | $columnMandatory = "on"; |
132 | - if(in_array($column,['created_at','updated_at'])) { |
|
132 | + if (in_array($column, ['created_at', 'updated_at'])) { |
|
133 | 133 | $columnAdd = ""; |
134 | 134 | $columnEdit = ""; |
135 | 135 | $columnMandatory = ""; |
@@ -174,41 +174,41 @@ discard block |
||
174 | 174 | public function postCreateMigration() |
175 | 175 | { |
176 | 176 | try { |
177 | - cb()->validation(['table_name','structures']); |
|
177 | + cb()->validation(['table_name', 'structures']); |
|
178 | 178 | |
179 | 179 | $tableName = request("table_name"); |
180 | 180 | |
181 | - if(!Schema::hasTable($tableName)) { |
|
181 | + if (!Schema::hasTable($tableName)) { |
|
182 | 182 | $filenameMigration = date("Y_m_d_His")."_".$tableName.".php"; |
183 | 183 | $createTemplate = file_get_contents(base_path("vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/create.stub")); |
184 | 184 | $className = Str::studly($tableName); |
185 | 185 | $createTemplate = str_replace("DummyClass", $className, $createTemplate); |
186 | 186 | $createTemplate = str_replace("DummyTable", $tableName, $createTemplate); |
187 | - $createTemplate = str_replace("\$table->increments('id');","",$createTemplate); |
|
188 | - $createTemplate = str_replace("\$table->bigIncrements('id');","",$createTemplate); |
|
189 | - $createTemplate = str_replace("\$table->timestamps();","{structure}",$createTemplate); |
|
187 | + $createTemplate = str_replace("\$table->increments('id');", "", $createTemplate); |
|
188 | + $createTemplate = str_replace("\$table->bigIncrements('id');", "", $createTemplate); |
|
189 | + $createTemplate = str_replace("\$table->timestamps();", "{structure}", $createTemplate); |
|
190 | 190 | |
191 | 191 | $structureItems = ""; |
192 | 192 | |
193 | - if(request("timestamp")) { |
|
193 | + if (request("timestamp")) { |
|
194 | 194 | $structureItems .= "\$table->timestamps();\n\t\t\t"; |
195 | 195 | } |
196 | 196 | |
197 | - if(request("soft_deletes")) { |
|
197 | + if (request("soft_deletes")) { |
|
198 | 198 | $structureItems .= "\$table->softDeletes();\n\t\t\t"; |
199 | 199 | } |
200 | 200 | |
201 | - foreach(request("structures") as $item) { |
|
201 | + foreach (request("structures") as $item) { |
|
202 | 202 | |
203 | 203 | $nullable = ""; |
204 | 204 | |
205 | - if(!in_array($item['type_data'],["bigIncrements","increments","mediumIncrements","smallIncrements"])) { |
|
205 | + if (!in_array($item['type_data'], ["bigIncrements", "increments", "mediumIncrements", "smallIncrements"])) { |
|
206 | 206 | $nullable = "->nullable()"; |
207 | 207 | } |
208 | 208 | |
209 | - if($item['length']) { |
|
209 | + if ($item['length']) { |
|
210 | 210 | $structureItems .= "\$table->".$item['type_data']."('".$item['field_name']."', ".$item['length'].")$nullable;\n\t\t\t"; |
211 | - }else{ |
|
211 | + } else { |
|
212 | 212 | $structureItems .= "\$table->".$item['type_data']."('".$item['field_name']."')$nullable;\n\t\t\t"; |
213 | 213 | } |
214 | 214 | } |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | } catch (CBValidationException $e) { |
230 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
230 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
231 | 231 | } catch (\Exception $e) { |
232 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
232 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
233 | 233 | } |
234 | 234 | |
235 | - return response()->json(['status'=>true,'message'=>'Migration successfully!']); |
|
235 | + return response()->json(['status'=>true, 'message'=>'Migration successfully!']); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | public function postCheckExistModule() |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | try { |
241 | 241 | cb()->validation(['name', 'table']); |
242 | 242 | |
243 | - if(DB::table("cb_modules")->where("table_name",request("table"))->where("name",request("name"))->count()) { |
|
243 | + if (DB::table("cb_modules")->where("table_name", request("table"))->where("name", request("name"))->count()) { |
|
244 | 244 | return response()->json(['status'=>true]); |
245 | 245 | } |
246 | 246 | |
247 | 247 | } catch (CBValidationException $e) { |
248 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
248 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | return response()->json(['status'=>false]); |
@@ -254,30 +254,30 @@ discard block |
||
254 | 254 | public function postAddSave() { |
255 | 255 | |
256 | 256 | try { |
257 | - cb()->validation(['name', 'table','icon','columns']); |
|
257 | + cb()->validation(['name', 'table', 'icon', 'columns']); |
|
258 | 258 | |
259 | 259 | $module = (new ModuleGenerator(request('table'), request('name'), request('icon'), request("columns"), request("rebuild")))->make(); |
260 | 260 | |
261 | 261 | } catch (CBValidationException $e) { |
262 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
262 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | return response()->json(['status'=>true, 'message'=>'Please remember that you can still modify the structure by edit the controller file '.$module['controller'].' :)']); |
266 | 266 | } |
267 | 267 | |
268 | 268 | public function getDelete($id) { |
269 | - $module = cb()->find("cb_modules",$id); |
|
269 | + $module = cb()->find("cb_modules", $id); |
|
270 | 270 | @unlink(app_path("Http/Controllers/".$module->controller.".php")); |
271 | 271 | DB::table("cb_modules")->where("id", $id)->delete(); |
272 | 272 | DB::table("cb_menus")->where("cb_modules_id", $id)->delete(); |
273 | - return cb()->redirectBack("The module has been deleted!","success"); |
|
273 | + return cb()->redirectBack("The module has been deleted!", "success"); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | public function getDeleteSoft($id) { |
277 | - $module = cb()->find("cb_modules",$id); |
|
277 | + $module = cb()->find("cb_modules", $id); |
|
278 | 278 | DB::table("cb_modules")->where("id", $id)->delete(); |
279 | 279 | DB::table("cb_menus")->where("cb_modules_id", $id)->delete(); |
280 | - return cb()->redirectBack("The module has been deleted!","success"); |
|
280 | + return cb()->redirectBack("The module has been deleted!", "success"); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | } |
284 | 284 | \ No newline at end of file |
@@ -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 | } |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | |
26 | 26 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
27 | 27 | |
28 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
29 | - if($softDelete === true && SchemaHelper::hasColumn($this->data['table'],'deleted_at')) { |
|
28 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
29 | + if ($softDelete === true && SchemaHelper::hasColumn($this->data['table'], 'deleted_at')) { |
|
30 | 30 | $query->whereNull($this->data['table'].'.deleted_at'); |
31 | 31 | } |
32 | 32 | |
33 | - if(isset($joins)) { |
|
34 | - foreach($joins as $join) |
|
33 | + if (isset($joins)) { |
|
34 | + foreach ($joins as $join) |
|
35 | 35 | { |
36 | 36 | $query->join($join['target_table'], |
37 | 37 | $join['target_table_primary'], |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - foreach($columns as $column) { |
|
44 | + foreach ($columns as $column) { |
|
45 | 45 | /** @var ColumnModel $column */ |
46 | - if($column->getType() != "custom") { |
|
47 | - if(strpos($column->getField(),".") === false) { |
|
48 | - if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
46 | + if ($column->getType() != "custom") { |
|
47 | + if (strpos($column->getField(), ".") === false) { |
|
48 | + if (SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
49 | 49 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
50 | 50 | } |
51 | - }else{ |
|
51 | + } else { |
|
52 | 52 | $query->addSelect($column->getField()); |
53 | 53 | } |
54 | 54 | } |
@@ -57,27 +57,27 @@ discard block |
||
57 | 57 | $query = getTypeHook($column->getType())->query($query, $column); |
58 | 58 | |
59 | 59 | // Filter Query From Type |
60 | - $filterValue = request("filter_".slug($column->getFilterColumn(),"_")); |
|
61 | - if(is_array($filterValue) || sanitizeXSS($filterValue)) { |
|
60 | + $filterValue = request("filter_".slug($column->getFilterColumn(), "_")); |
|
61 | + if (is_array($filterValue) || sanitizeXSS($filterValue)) { |
|
62 | 62 | $query = getTypeHook($column->getType())->filterQuery($query, $column, $filterValue); |
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - if(request()->has('q')) |
|
66 | + if (request()->has('q')) |
|
67 | 67 | { |
68 | 68 | $keyword = sanitizeXSS(request("q")); |
69 | - if(isset($this->data['hook_search_query'])) { |
|
69 | + if (isset($this->data['hook_search_query'])) { |
|
70 | 70 | $query = call_user_func($this->data['hook_search_query'], $query, $keyword); |
71 | - }else{ |
|
72 | - $query->where(function ($where) use ($columns, $keyword) { |
|
71 | + } else { |
|
72 | + $query->where(function($where) use ($columns, $keyword) { |
|
73 | 73 | /** |
74 | 74 | * @var $where Builder |
75 | 75 | */ |
76 | - foreach($columns as $column) |
|
76 | + foreach ($columns as $column) |
|
77 | 77 | { |
78 | - if(strpos($column->getField(),".") === false) { |
|
78 | + if (strpos($column->getField(), ".") === false) { |
|
79 | 79 | $field = $this->data['table'].'.'.$column->getField(); |
80 | - }else{ |
|
80 | + } else { |
|
81 | 81 | $field = $column->getField(); |
82 | 82 | } |
83 | 83 | $where->orWhere($field, 'like', '%'.$keyword.'%'); |
@@ -90,36 +90,36 @@ discard block |
||
90 | 90 | /* |
91 | 91 | * This script to hanlde the callback inputed on this query method |
92 | 92 | */ |
93 | - if(isset($callback) && is_callable($callback)) { |
|
93 | + if (isset($callback) && is_callable($callback)) { |
|
94 | 94 | $query = call_user_func($callback, $query); |
95 | 95 | } |
96 | 96 | |
97 | - if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
97 | + if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
98 | 98 | $query = call_user_func($this->data['hook_index_query'], $query); |
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | - if(request()->has(['order_by','order_sort'])) |
|
102 | + if (request()->has(['order_by', 'order_sort'])) |
|
103 | 103 | { |
104 | - $sort = (request("order_sort")=="asc")?"asc":"desc"; |
|
104 | + $sort = (request("order_sort") == "asc") ? "asc" : "desc"; |
|
105 | 105 | /* |
106 | 106 | * Check if order by contain "." it means {table}.{column} we have to parsing that |
107 | 107 | */ |
108 | - if(strpos(request("order_by"), ".")!==false) { |
|
109 | - $orderByTable = explode(".",request("order_by"))[0]; |
|
110 | - $orderByColumn = explode(".",request("order_by"))[1]; |
|
111 | - if(SchemaHelper::hasColumn($orderByTable, $orderByColumn)) { |
|
108 | + if (strpos(request("order_by"), ".") !== false) { |
|
109 | + $orderByTable = explode(".", request("order_by"))[0]; |
|
110 | + $orderByColumn = explode(".", request("order_by"))[1]; |
|
111 | + if (SchemaHelper::hasColumn($orderByTable, $orderByColumn)) { |
|
112 | 112 | $query->orderBy($orderByTable.".".$orderByColumn, $sort); |
113 | 113 | } |
114 | 114 | } else { |
115 | 115 | /* |
116 | 116 | * Check if order_by column in registered columns |
117 | 117 | */ |
118 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
118 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
119 | 119 | $query->orderBy(request('order_by'), request('order_sort')); |
120 | 120 | } |
121 | 121 | } |
122 | - }else{ |
|
122 | + } else { |
|
123 | 123 | /* |
124 | 124 | * For default, query will be order by primary key as descending |
125 | 125 | */ |
@@ -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(); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | public function headers(array $headers) { |
51 | 51 | $newHeaders = []; |
52 | - foreach($headers as $key=>$val) { |
|
52 | + foreach ($headers as $key=>$val) { |
|
53 | 53 | $newHeaders[] = $key.": ".$val; |
54 | 54 | } |
55 | 55 | $this->headers = $newHeaders; |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
69 | 69 | curl_setopt($ch, CURLOPT_POSTFIELDS, $this->data); |
70 | 70 | curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); |
71 | - curl_setopt($ch,CURLOPT_USERAGENT,$this->user_agent); |
|
71 | + curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); |
|
72 | 72 | curl_setopt($ch, CURLOPT_REFERER, $this->referer); |
73 | - if($this->cookie === true) { |
|
73 | + if ($this->cookie === true) { |
|
74 | 74 | $cookie_dir = storage_path("cookies"); |
75 | - if(!file_exists($cookie_dir)) mkdir($cookie_dir); |
|
75 | + if (!file_exists($cookie_dir)) mkdir($cookie_dir); |
|
76 | 76 | $cookie_file = $cookie_dir."/".md5(request()->ip()).".txt"; |
77 | 77 | curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); |
78 | 78 | curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | $err = curl_error($ch); |
83 | 83 | curl_close($ch); |
84 | 84 | |
85 | - if($err) { |
|
85 | + if ($err) { |
|
86 | 86 | return $err; |
87 | - }else { |
|
87 | + } else { |
|
88 | 88 | return $response; |
89 | 89 | } |
90 | 90 | } |