@@ -1,48 +1,48 @@ 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()->routePost("skip-tutorial","DeveloperDashboardController@postSkipTutorial"); |
|
15 | - 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()->routePost("skip-tutorial", "DeveloperDashboardController@postSkipTutorial"); |
|
15 | + cb()->routeGet("/", "DeveloperDashboardController@getIndex"); |
|
16 | 16 | }); |
17 | 17 | |
18 | 18 | // Developer Auth Middleware |
19 | 19 | Route::group(['middleware' => ['web'], |
20 | 20 | 'prefix'=>"developer/".getSetting('developer_path'), |
21 | - 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
22 | - cb()->routePost("login","AdminAuthController@postLoginDeveloper"); |
|
23 | - cb()->routeGet("login","AdminAuthController@getLoginDeveloper"); |
|
24 | - cb()->routeGet("logout","AdminAuthController@getLogoutDeveloper"); |
|
21 | + 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
22 | + cb()->routePost("login", "AdminAuthController@postLoginDeveloper"); |
|
23 | + cb()->routeGet("login", "AdminAuthController@getLoginDeveloper"); |
|
24 | + cb()->routeGet("logout", "AdminAuthController@getLogoutDeveloper"); |
|
25 | 25 | }); |
26 | 26 | |
27 | 27 | // Routing without any middleware |
28 | -Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () { |
|
29 | - if(env("CB_AUTO_REDIRECT_TO_LOGIN")) { |
|
30 | - cb()->routeGet("/","AdminAuthController@getRedirectToLogin"); |
|
28 | +Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() { |
|
29 | + if (env("CB_AUTO_REDIRECT_TO_LOGIN")) { |
|
30 | + cb()->routeGet("/", "AdminAuthController@getRedirectToLogin"); |
|
31 | 31 | } |
32 | 32 | }); |
33 | 33 | |
34 | 34 | // Routing without any middleware with admin prefix |
35 | -Route::group(['middleware' => ['web'], 'prefix' => env('CB_ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () { |
|
35 | +Route::group(['middleware' => ['web'], 'prefix' => env('CB_ADMIN_PATH'), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() { |
|
36 | 36 | cb()->routeGet('logout', "AdminAuthController@getLogout"); |
37 | 37 | |
38 | - if(!env("CB_DISABLE_LOGIN")) { |
|
38 | + if (!env("CB_DISABLE_LOGIN")) { |
|
39 | 39 | cb()->routePost('login', "AdminAuthController@postLogin"); |
40 | 40 | cb()->routeGet('login', "AdminAuthController@getLogin"); |
41 | 41 | } |
42 | 42 | }); |
43 | 43 | |
44 | 44 | // Routing package controllers |
45 | -cb()->routeGroupBackend(function () { |
|
45 | +cb()->routeGroupBackend(function() { |
|
46 | 46 | cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController'); |
47 | 47 | }); |
48 | 48 | |
@@ -51,24 +51,24 @@ discard block |
||
51 | 51 | 'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class], |
52 | 52 | 'prefix' => env('CB_ADMIN_PATH'), |
53 | 53 | 'namespace' => 'App\Http\Controllers', |
54 | -], function () { |
|
54 | +], function() { |
|
55 | 55 | |
56 | 56 | if (Request::is(env('CB_ADMIN_PATH'))) { |
57 | - if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
|
57 | + if ($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
|
58 | 58 | cb()->routeGet("/", $dashboard); |
59 | - }else{ |
|
59 | + } else { |
|
60 | 60 | cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | 64 | $controllers = glob(app_path('Http/Controllers/Admin*Controller.php')); |
65 | 65 | |
66 | - foreach($controllers as $controller) { |
|
66 | + foreach ($controllers as $controller) { |
|
67 | 67 | $controllerName = basename($controller); |
68 | - $controllerName = rtrim($controllerName,".php"); |
|
68 | + $controllerName = rtrim($controllerName, ".php"); |
|
69 | 69 | $className = '\App\Http\Controllers\\'.$controllerName; |
70 | 70 | $controllerClass = new $className(); |
71 | - if(method_exists($controllerClass, 'cbInit')) { |
|
71 | + if (method_exists($controllerClass, 'cbInit')) { |
|
72 | 72 | cb()->routeController($controllerClass->getData('permalink'), $controllerName); |
73 | 73 | } |
74 | 74 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | if (Request::is(env('CB_ADMIN_PATH'))) { |
57 | 57 | if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
58 | 58 | cb()->routeGet("/", $dashboard); |
59 | - }else{ |
|
59 | + } else{ |
|
60 | 60 | cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
61 | 61 | } |
62 | 62 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | public function getRoleByName($roleName) { |
23 | - return $this->find("cb_roles",['name'=>$roleName]); |
|
23 | + return $this->find("cb_roles", ['name'=>$roleName]); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function fcm() { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getDeveloperUrl($path = null) { |
39 | - $path = ($path)?"/".trim($path,"/"):null; |
|
39 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
40 | 40 | return url("developer/".getSetting("developer_path")).$path; |
41 | 41 | } |
42 | 42 | |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | public function getAdminUrl($path = null) { |
56 | - $path = ($path)?"/".trim($path,"/"):null; |
|
56 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
57 | 57 | return url(env("CB_ADMIN_PATH")).$path; |
58 | 58 | } |
59 | 59 | |
60 | 60 | public function getAppName() { |
61 | - return env("APP_NAME","CRUDBOOSTER"); |
|
61 | + return env("APP_NAME", "CRUDBOOSTER"); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | */ |
73 | 73 | private function uploadFileProcess($filename, $extension, $file, $encrypt = true, $resize_width = null, $resize_height = null) |
74 | 74 | { |
75 | - if(in_array($extension,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
75 | + if (in_array($extension, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
76 | 76 | $file_path = cbConfig("UPLOAD_PATH_FORMAT"); |
77 | - $file_path = str_replace("{Y}",date('Y'), $file_path); |
|
77 | + $file_path = str_replace("{Y}", date('Y'), $file_path); |
|
78 | 78 | $file_path = str_replace("{m}", date('m'), $file_path); |
79 | 79 | $file_path = str_replace("{d}", date("d"), $file_path); |
80 | 80 | |
81 | 81 | //Create Directory Base On Template |
82 | 82 | Storage::makeDirectory($file_path); |
83 | - Storage::put($file_path."/index.html"," ","public"); |
|
84 | - Storage::put($file_path."/.gitignore","!.gitignore","public"); |
|
83 | + Storage::put($file_path."/index.html", " ", "public"); |
|
84 | + Storage::put($file_path."/.gitignore", "!.gitignore", "public"); |
|
85 | 85 | |
86 | 86 | if ($encrypt == true) { |
87 | 87 | $filename = md5(strRandom(5)).'.'.$extension; |
@@ -89,17 +89,17 @@ discard block |
||
89 | 89 | $filename = slug($filename, '_').'.'.$extension; |
90 | 90 | } |
91 | 91 | |
92 | - if($resize_width || $resize_height) { |
|
92 | + if ($resize_width || $resize_height) { |
|
93 | 93 | $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height); |
94 | 94 | return $file_path.'/'.$filename; |
95 | - }else{ |
|
95 | + } else { |
|
96 | 96 | if (Storage::put($file_path.'/'.$filename, $file, 'public')) { |
97 | 97 | return $file_path.'/'.$filename; |
98 | 98 | } else { |
99 | 99 | throw new \Exception("Something went wrong, file can't upload!"); |
100 | 100 | } |
101 | 101 | } |
102 | - }else{ |
|
102 | + } else { |
|
103 | 103 | throw new \Exception("The file format is not allowed!"); |
104 | 104 | } |
105 | 105 | } |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | { |
116 | 116 | $fileData = base64_decode($base64_value); |
117 | 117 | $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE); |
118 | - if($mime_type) { |
|
119 | - if($mime_type = explode('/', $mime_type)) { |
|
118 | + if ($mime_type) { |
|
119 | + if ($mime_type = explode('/', $mime_type)) { |
|
120 | 120 | $ext = $mime_type[1]; |
121 | - if($filename && $ext) { |
|
121 | + if ($filename && $ext) { |
|
122 | 122 | return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height); |
123 | 123 | } |
124 | - }else { |
|
124 | + } else { |
|
125 | 125 | throw new \Exception("Mime type not found"); |
126 | 126 | } |
127 | - }else{ |
|
127 | + } else { |
|
128 | 128 | throw new \Exception("Mime type not found"); |
129 | 129 | } |
130 | 130 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $filename = $file->getClientOriginalName(); |
145 | 145 | $ext = strtolower($file->getClientOriginalExtension()); |
146 | 146 | |
147 | - if($filename && $ext) { |
|
147 | + if ($filename && $ext) { |
|
148 | 148 | return $this->uploadFileProcess($filename, $ext, $file, $encrypt, $resize_width, $resize_height); |
149 | 149 | } |
150 | 150 | |
@@ -179,29 +179,29 @@ discard block |
||
179 | 179 | if ($resize_width && $resize_height) { |
180 | 180 | $img->fit($resize_width, $resize_height); |
181 | 181 | |
182 | - } elseif ($resize_width && ! $resize_height) { |
|
182 | + } elseif ($resize_width && !$resize_height) { |
|
183 | 183 | |
184 | - $img->resize($resize_width, null, function ($constraint) { |
|
184 | + $img->resize($resize_width, null, function($constraint) { |
|
185 | 185 | $constraint->aspectRatio(); |
186 | 186 | }); |
187 | 187 | |
188 | - } elseif (! $resize_width && $resize_height) { |
|
188 | + } elseif (!$resize_width && $resize_height) { |
|
189 | 189 | |
190 | - $img->resize(null, $resize_height, function ($constraint) { |
|
190 | + $img->resize(null, $resize_height, function($constraint) { |
|
191 | 191 | $constraint->aspectRatio(); |
192 | 192 | }); |
193 | 193 | |
194 | 194 | } else { |
195 | 195 | |
196 | 196 | if ($img->width() > cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES")) { |
197 | - $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function ($constraint) { |
|
197 | + $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function($constraint) { |
|
198 | 198 | $constraint->aspectRatio(); |
199 | 199 | }); |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | Storage::put($fullFilePath, $img, 'public'); |
204 | - }else{ |
|
204 | + } else { |
|
205 | 205 | throw new \Exception("The file format is not allowed!"); |
206 | 206 | } |
207 | 207 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $validator = Validator::make($input_arr, $rules, $messages); |
315 | 315 | if ($validator->fails()) { |
316 | 316 | $message = $validator->errors()->all(); |
317 | - throw new CBValidationException(implode("; ",$message)); |
|
317 | + throw new CBValidationException(implode("; ", $message)); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | public function findPrimaryKey($table) |
327 | 327 | { |
328 | 328 | $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey(); |
329 | - if(!$pk) { |
|
329 | + if (!$pk) { |
|
330 | 330 | return null; |
331 | 331 | } |
332 | 332 | return $pk->getColumns()[0]; |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $string_parameters_array = explode('&', $string_parameters); |
376 | 376 | foreach ($string_parameters_array as $s) { |
377 | 377 | $part = explode('=', $s); |
378 | - if(isset($part[0]) && isset($part[1])) { |
|
378 | + if (isset($part[0]) && isset($part[1])) { |
|
379 | 379 | $name = htmlspecialchars(urldecode($part[0])); |
380 | 380 | $name = strip_tags($name); |
381 | 381 | $value = htmlspecialchars(urldecode($part[1])); |
@@ -392,16 +392,16 @@ discard block |
||
392 | 392 | |
393 | 393 | |
394 | 394 | public function routeGet($prefix, $controller) { |
395 | - $alias = str_replace("@"," ", $controller); |
|
395 | + $alias = str_replace("@", " ", $controller); |
|
396 | 396 | $alias = ucwords($alias); |
397 | - $alias = str_replace(" ","",$alias); |
|
397 | + $alias = str_replace(" ", "", $alias); |
|
398 | 398 | Route::get($prefix, ['uses' => $controller, 'as' => $alias]); |
399 | 399 | } |
400 | 400 | |
401 | 401 | public function routePost($prefix, $controller) { |
402 | - $alias = str_replace("@"," ", $controller); |
|
402 | + $alias = str_replace("@", " ", $controller); |
|
403 | 403 | $alias = ucwords($alias); |
404 | - $alias = str_replace(" ","",$alias); |
|
404 | + $alias = str_replace(" ", "", $alias); |
|
405 | 405 | Route::post($prefix, ['uses' => $controller, 'as' => $alias]); |
406 | 406 | } |
407 | 407 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | |
427 | 427 | $prefix = trim($prefix, '/').'/'; |
428 | 428 | |
429 | - if(substr($controller,0,1) != "\\") { |
|
429 | + if (substr($controller, 0, 1) != "\\") { |
|
430 | 430 | $controller = "\App\Http\Controllers\\".$controller; |
431 | 431 | } |
432 | 432 |