@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getRoleByName($roleName) { |
27 | - return $this->find("cb_roles",['name'=>$roleName]); |
|
27 | + return $this->find("cb_roles", ['name'=>$roleName]); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function fcm() { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | public function getDeveloperUrl($path = null) { |
43 | - $path = ($path)?"/".trim($path,"/"):null; |
|
43 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
44 | 44 | return url("developer/".getSetting("developer_path")).$path; |
45 | 45 | } |
46 | 46 | |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | public function getAdminPath() { |
60 | - return getSetting("ADMIN_PATH","admin"); |
|
60 | + return getSetting("ADMIN_PATH", "admin"); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public function getAdminUrl($path = null) { |
64 | - $path = ($path)?"/".trim($path,"/"):null; |
|
64 | + $path = ($path) ? "/".trim($path, "/") : null; |
|
65 | 65 | return url($this->getAdminPath()).$path; |
66 | 66 | } |
67 | 67 | |
68 | 68 | public function getAppName() { |
69 | - return getSetting("APP_NAME", env("APP_NAME","CRUDBOOSTER")); |
|
69 | + return getSetting("APP_NAME", env("APP_NAME", "CRUDBOOSTER")); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | */ |
81 | 81 | private function uploadFileProcess($filename, $extension, $file, $encrypt = true, $resize_width = null, $resize_height = null) |
82 | 82 | { |
83 | - if(in_array($extension,cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
83 | + if (in_array($extension, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) { |
|
84 | 84 | $file_path = cbConfig("UPLOAD_PATH_FORMAT"); |
85 | - $file_path = str_replace("{Y}",date('Y'), $file_path); |
|
85 | + $file_path = str_replace("{Y}", date('Y'), $file_path); |
|
86 | 86 | $file_path = str_replace("{m}", date('m'), $file_path); |
87 | 87 | $file_path = str_replace("{d}", date("d"), $file_path); |
88 | 88 | |
89 | 89 | //Create Directory Base On Template |
90 | 90 | Storage::makeDirectory($file_path); |
91 | - Storage::put($file_path."/index.html"," ","public"); |
|
92 | - Storage::put($file_path."/.gitignore","!.gitignore","public"); |
|
91 | + Storage::put($file_path."/index.html", " ", "public"); |
|
92 | + Storage::put($file_path."/.gitignore", "!.gitignore", "public"); |
|
93 | 93 | |
94 | 94 | if ($encrypt == true) { |
95 | 95 | $filename = md5(strRandom(5)).'.'.$extension; |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | $filename = slug($filename, '_').'.'.$extension; |
98 | 98 | } |
99 | 99 | |
100 | - if($resize_width || $resize_height) { |
|
100 | + if ($resize_width || $resize_height) { |
|
101 | 101 | $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height); |
102 | 102 | return $file_path.'/'.$filename; |
103 | - }else{ |
|
103 | + } else { |
|
104 | 104 | if (Storage::putFileAs($file_path, $file, $filename, 'public')) { |
105 | 105 | return $file_path.'/'.$filename; |
106 | 106 | } else { |
107 | 107 | throw new \Exception("Something went wrong, file can't upload!"); |
108 | 108 | } |
109 | 109 | } |
110 | - }else{ |
|
110 | + } else { |
|
111 | 111 | throw new \Exception("The file format is not allowed!"); |
112 | 112 | } |
113 | 113 | } |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | { |
124 | 124 | $fileData = base64_decode($base64_value); |
125 | 125 | $mime_type = finfo_buffer(finfo_open(), $fileData, FILEINFO_MIME_TYPE); |
126 | - if($mime_type) { |
|
127 | - if($mime_type = explode('/', $mime_type)) { |
|
126 | + if ($mime_type) { |
|
127 | + if ($mime_type = explode('/', $mime_type)) { |
|
128 | 128 | $ext = $mime_type[1]; |
129 | - if($filename && $ext) { |
|
129 | + if ($filename && $ext) { |
|
130 | 130 | return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height); |
131 | 131 | } |
132 | - }else { |
|
132 | + } else { |
|
133 | 133 | throw new \Exception("Mime type not found"); |
134 | 134 | } |
135 | - }else{ |
|
135 | + } else { |
|
136 | 136 | throw new \Exception("Mime type not found"); |
137 | 137 | } |
138 | 138 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $filename = $file->getClientOriginalName(); |
153 | 153 | $ext = strtolower($file->getClientOriginalExtension()); |
154 | 154 | |
155 | - if($filename && $ext) { |
|
155 | + if ($filename && $ext) { |
|
156 | 156 | return $this->uploadFileProcess($filename, $ext, $file, $encrypt, $resize_width, $resize_height); |
157 | 157 | } |
158 | 158 | |
@@ -187,29 +187,29 @@ discard block |
||
187 | 187 | if ($resize_width && $resize_height) { |
188 | 188 | $img->fit($resize_width, $resize_height); |
189 | 189 | |
190 | - } elseif ($resize_width && ! $resize_height) { |
|
190 | + } elseif ($resize_width && !$resize_height) { |
|
191 | 191 | |
192 | - $img->resize($resize_width, null, function ($constraint) { |
|
192 | + $img->resize($resize_width, null, function($constraint) { |
|
193 | 193 | $constraint->aspectRatio(); |
194 | 194 | }); |
195 | 195 | |
196 | - } elseif (! $resize_width && $resize_height) { |
|
196 | + } elseif (!$resize_width && $resize_height) { |
|
197 | 197 | |
198 | - $img->resize(null, $resize_height, function ($constraint) { |
|
198 | + $img->resize(null, $resize_height, function($constraint) { |
|
199 | 199 | $constraint->aspectRatio(); |
200 | 200 | }); |
201 | 201 | |
202 | 202 | } else { |
203 | 203 | |
204 | 204 | if ($img->width() > cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES")) { |
205 | - $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function ($constraint) { |
|
205 | + $img->resize(cbConfig("DEFAULT_IMAGE_MAX_WIDTH_RES"), null, function($constraint) { |
|
206 | 206 | $constraint->aspectRatio(); |
207 | 207 | }); |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | 211 | Storage::put($fullFilePath, $img, 'public'); |
212 | - }else{ |
|
212 | + } else { |
|
213 | 213 | throw new \Exception("The file format is not allowed!"); |
214 | 214 | } |
215 | 215 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | { |
234 | 234 | if (is_array($id)) { |
235 | 235 | $idHash = md5("find".$table.serialize($id)); |
236 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
236 | + if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
237 | 237 | |
238 | 238 | $first = DB::table($table); |
239 | 239 | foreach ($id as $k => $v) { |
@@ -241,15 +241,15 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | $data = $first->first(); |
244 | - miscellanousSingleton()->setData($idHash,$data); |
|
244 | + miscellanousSingleton()->setData($idHash, $data); |
|
245 | 245 | return $data; |
246 | 246 | } else { |
247 | 247 | $idHash = md5("find".$table.$id); |
248 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
248 | + if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
249 | 249 | |
250 | 250 | $pk = $this->pk($table); |
251 | 251 | $data = DB::table($table)->where($pk, $id)->first(); |
252 | - miscellanousSingleton()->setData($idHash,$data); |
|
252 | + miscellanousSingleton()->setData($idHash, $data); |
|
253 | 253 | return $data; |
254 | 254 | } |
255 | 255 | } |
@@ -264,30 +264,30 @@ discard block |
||
264 | 264 | $data = []; |
265 | 265 | $idHash = null; |
266 | 266 | |
267 | - if(is_array($conditionOrCallback)) { |
|
267 | + if (is_array($conditionOrCallback)) { |
|
268 | 268 | $idHash = md5("findAll".$table.serialize($conditionOrCallback)); |
269 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
269 | + if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
270 | 270 | |
271 | 271 | $data = DB::table($table)->where($conditionOrCallback)->get(); |
272 | 272 | } elseif (is_callable($conditionOrCallback)) { |
273 | 273 | $idHash = "findAll".$table.spl_object_hash($conditionOrCallback); |
274 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
274 | + if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
275 | 275 | |
276 | 276 | $data = DB::table($table); |
277 | 277 | $data = call_user_func($conditionOrCallback, $data); |
278 | 278 | $data = $data->get(); |
279 | 279 | } else { |
280 | 280 | $idHash = md5("findAll".$table.$conditionOrCallback); |
281 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
281 | + if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
282 | 282 | |
283 | 283 | $data = DB::table($table); |
284 | - if($conditionOrCallback) { |
|
284 | + if ($conditionOrCallback) { |
|
285 | 285 | $data = $data->whereRaw($conditionOrCallback); |
286 | 286 | } |
287 | 287 | $data = $data->get(); |
288 | 288 | } |
289 | 289 | |
290 | - if($idHash && $data) { |
|
290 | + if ($idHash && $data) { |
|
291 | 291 | miscellanousSingleton()->setData($idHash, $data); |
292 | 292 | } |
293 | 293 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | public function listAllTable() |
298 | 298 | { |
299 | 299 | $idHash = md5("listAllTable"); |
300 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
300 | + if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
301 | 301 | $data = DB::connection()->getDoctrineSchemaManager()->listTableNames(); |
302 | 302 | miscellanousSingleton()->setData($idHash, $data); |
303 | 303 | return $data; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | public function listAllColumns($table) |
307 | 307 | { |
308 | 308 | $idHash = md5("listAllColumns".$table); |
309 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
309 | + if (miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
310 | 310 | $data = Schema::getColumnListing($table); |
311 | 311 | miscellanousSingleton()->setData($idHash, $data); |
312 | 312 | return $data; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $validator = Validator::make($input_arr, $rules, $messages); |
375 | 375 | if ($validator->fails()) { |
376 | 376 | $message = $validator->errors()->all(); |
377 | - throw new CBValidationException(implode("; ",$message)); |
|
377 | + throw new CBValidationException(implode("; ", $message)); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | public function findPrimaryKey($table) |
387 | 387 | { |
388 | 388 | $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey(); |
389 | - if(!$pk) { |
|
389 | + if (!$pk) { |
|
390 | 390 | return null; |
391 | 391 | } |
392 | 392 | return $pk->getColumns()[0]; |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $string_parameters_array = explode('&', $string_parameters); |
436 | 436 | foreach ($string_parameters_array as $s) { |
437 | 437 | $part = explode('=', $s); |
438 | - if(isset($part[0]) && isset($part[1])) { |
|
438 | + if (isset($part[0]) && isset($part[1])) { |
|
439 | 439 | $name = htmlspecialchars(urldecode($part[0])); |
440 | 440 | $name = strip_tags($name); |
441 | 441 | $value = htmlspecialchars(urldecode($part[1])); |
@@ -452,16 +452,16 @@ discard block |
||
452 | 452 | |
453 | 453 | |
454 | 454 | public function routeGet($prefix, $controller) { |
455 | - $alias = str_replace("@"," ", $controller); |
|
455 | + $alias = str_replace("@", " ", $controller); |
|
456 | 456 | $alias = ucwords($alias); |
457 | - $alias = str_replace(" ","",$alias); |
|
457 | + $alias = str_replace(" ", "", $alias); |
|
458 | 458 | Route::get($prefix, ['uses' => $controller, 'as' => $alias]); |
459 | 459 | } |
460 | 460 | |
461 | 461 | public function routePost($prefix, $controller) { |
462 | - $alias = str_replace("@"," ", $controller); |
|
462 | + $alias = str_replace("@", " ", $controller); |
|
463 | 463 | $alias = ucwords($alias); |
464 | - $alias = str_replace(" ","",$alias); |
|
464 | + $alias = str_replace(" ", "", $alias); |
|
465 | 465 | Route::post($prefix, ['uses' => $controller, 'as' => $alias]); |
466 | 466 | } |
467 | 467 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | $prefix = trim($prefix, '/').'/'; |
496 | 496 | |
497 | - if(substr($controller,0,1) != "\\") { |
|
497 | + if (substr($controller, 0, 1) != "\\") { |
|
498 | 498 | $controller = "\App\Http\Controllers\\".$controller; |
499 | 499 | } |
500 | 500 |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | if($resize_width || $resize_height) { |
101 | 101 | $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height); |
102 | 102 | return $file_path.'/'.$filename; |
103 | - }else{ |
|
103 | + } else{ |
|
104 | 104 | if (Storage::putFileAs($file_path, $file, $filename, 'public')) { |
105 | 105 | return $file_path.'/'.$filename; |
106 | 106 | } else { |
107 | 107 | throw new \Exception("Something went wrong, file can't upload!"); |
108 | 108 | } |
109 | 109 | } |
110 | - }else{ |
|
110 | + } else{ |
|
111 | 111 | throw new \Exception("The file format is not allowed!"); |
112 | 112 | } |
113 | 113 | } |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | if($filename && $ext) { |
130 | 130 | return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height); |
131 | 131 | } |
132 | - }else { |
|
132 | + } else { |
|
133 | 133 | throw new \Exception("Mime type not found"); |
134 | 134 | } |
135 | - }else{ |
|
135 | + } else{ |
|
136 | 136 | throw new \Exception("Mime type not found"); |
137 | 137 | } |
138 | 138 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | Storage::put($fullFilePath, $img, 'public'); |
212 | - }else{ |
|
212 | + } else{ |
|
213 | 213 | throw new \Exception("The file format is not allowed!"); |
214 | 214 | } |
215 | 215 | } |
@@ -233,7 +233,9 @@ discard block |
||
233 | 233 | { |
234 | 234 | if (is_array($id)) { |
235 | 235 | $idHash = md5("find".$table.serialize($id)); |
236 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
236 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
237 | + return miscellanousSingleton()->getData($idHash); |
|
238 | + } |
|
237 | 239 | |
238 | 240 | $first = DB::table($table); |
239 | 241 | foreach ($id as $k => $v) { |
@@ -245,7 +247,9 @@ discard block |
||
245 | 247 | return $data; |
246 | 248 | } else { |
247 | 249 | $idHash = md5("find".$table.$id); |
248 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
250 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
251 | + return miscellanousSingleton()->getData($idHash); |
|
252 | + } |
|
249 | 253 | |
250 | 254 | $pk = $this->pk($table); |
251 | 255 | $data = DB::table($table)->where($pk, $id)->first(); |
@@ -266,19 +270,25 @@ discard block |
||
266 | 270 | |
267 | 271 | if(is_array($conditionOrCallback)) { |
268 | 272 | $idHash = md5("findAll".$table.serialize($conditionOrCallback)); |
269 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
273 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
274 | + return miscellanousSingleton()->getData($idHash); |
|
275 | + } |
|
270 | 276 | |
271 | 277 | $data = DB::table($table)->where($conditionOrCallback)->get(); |
272 | 278 | } elseif (is_callable($conditionOrCallback)) { |
273 | 279 | $idHash = "findAll".$table.spl_object_hash($conditionOrCallback); |
274 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
280 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
281 | + return miscellanousSingleton()->getData($idHash); |
|
282 | + } |
|
275 | 283 | |
276 | 284 | $data = DB::table($table); |
277 | 285 | $data = call_user_func($conditionOrCallback, $data); |
278 | 286 | $data = $data->get(); |
279 | 287 | } else { |
280 | 288 | $idHash = md5("findAll".$table.$conditionOrCallback); |
281 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
289 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
290 | + return miscellanousSingleton()->getData($idHash); |
|
291 | + } |
|
282 | 292 | |
283 | 293 | $data = DB::table($table); |
284 | 294 | if($conditionOrCallback) { |
@@ -297,7 +307,9 @@ discard block |
||
297 | 307 | public function listAllTable() |
298 | 308 | { |
299 | 309 | $idHash = md5("listAllTable"); |
300 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
310 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
311 | + return miscellanousSingleton()->getData($idHash); |
|
312 | + } |
|
301 | 313 | $data = DB::connection()->getDoctrineSchemaManager()->listTableNames(); |
302 | 314 | miscellanousSingleton()->setData($idHash, $data); |
303 | 315 | return $data; |
@@ -306,7 +318,9 @@ discard block |
||
306 | 318 | public function listAllColumns($table) |
307 | 319 | { |
308 | 320 | $idHash = md5("listAllColumns".$table); |
309 | - if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash); |
|
321 | + if(miscellanousSingleton()->hasData($idHash)) { |
|
322 | + return miscellanousSingleton()->getData($idHash); |
|
323 | + } |
|
310 | 324 | $data = Schema::getColumnListing($table); |
311 | 325 | miscellanousSingleton()->setData($idHash, $data); |
312 | 326 | return $data; |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | { |
16 | 16 | public static function putInGroup($key, $value, $group, $duration) { |
17 | 17 | $key = md5($key); |
18 | - $exist = (Cache::get($group))?:[]; |
|
19 | - $exist[ $key ] = ['value'=>$value,'duration'=>$duration]; |
|
18 | + $exist = (Cache::get($group)) ?: []; |
|
19 | + $exist[$key] = ['value'=>$value, 'duration'=>$duration]; |
|
20 | 20 | |
21 | - if($duration == -1) { |
|
21 | + if ($duration == -1) { |
|
22 | 22 | Cache::forever($group, $exist); |
23 | 23 | } else { |
24 | 24 | Cache::put($group, $exist, $duration); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public static function getItemInGroup($key, $group) { |
29 | 29 | $groupdata = Cache::get($group); |
30 | 30 | $key = md5($key); |
31 | - if(isset($groupdata[$key])) { |
|
31 | + if (isset($groupdata[$key])) { |
|
32 | 32 | return $groupdata[$key]['value']; |
33 | 33 | } |
34 | 34 | return null; |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | Cache::forget($group); |
39 | 39 | } |
40 | 40 | |
41 | - public static function forgetInGroup($key,$group) { |
|
41 | + public static function forgetInGroup($key, $group) { |
|
42 | 42 | $key = md5($key); |
43 | 43 | $data = Cache::get($group); |
44 | 44 | $duration = null; |
45 | - if(isset($data[$key])) { |
|
45 | + if (isset($data[$key])) { |
|
46 | 46 | $item = $data[$key]; |
47 | 47 | unset($data[$key]); |
48 | 48 | } |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | |
25 | 25 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
26 | 26 | |
27 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
28 | - if($softDelete === true && SchemaHelper::hasColumn($this->data['table'],'deleted_at')) { |
|
27 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
28 | + if ($softDelete === true && SchemaHelper::hasColumn($this->data['table'], 'deleted_at')) { |
|
29 | 29 | $query->whereNull($this->data['table'].'.deleted_at'); |
30 | 30 | } |
31 | 31 | |
32 | - if(isset($joins)) { |
|
33 | - foreach($joins as $join) |
|
32 | + if (isset($joins)) { |
|
33 | + foreach ($joins as $join) |
|
34 | 34 | { |
35 | 35 | $query->join($join['target_table'], |
36 | 36 | $join['target_table_primary'], |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | - foreach($columns as $column) { |
|
43 | + foreach ($columns as $column) { |
|
44 | 44 | /** @var ColumnModel $column */ |
45 | - if($column->getType() != "custom") { |
|
46 | - if(strpos($column->getField(),".") === false) { |
|
47 | - if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
45 | + if ($column->getType() != "custom") { |
|
46 | + if (strpos($column->getField(), ".") === false) { |
|
47 | + if (SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
|
48 | 48 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
49 | 49 | } |
50 | - }else{ |
|
50 | + } else { |
|
51 | 51 | $query->addSelect($column->getField()); |
52 | 52 | } |
53 | 53 | } |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | $query = getTypeHook($column->getType())->query($query, $column); |
56 | 56 | } |
57 | 57 | |
58 | - if(request()->has('q')) |
|
58 | + if (request()->has('q')) |
|
59 | 59 | { |
60 | 60 | $keyword = sanitizeXSS(request("q")); |
61 | - if(isset($this->data['hook_search_query'])) { |
|
61 | + if (isset($this->data['hook_search_query'])) { |
|
62 | 62 | $query = call_user_func($this->data['hook_search_query'], $query); |
63 | - }else{ |
|
64 | - $query->where(function ($where) use ($columns, $keyword) { |
|
63 | + } else { |
|
64 | + $query->where(function($where) use ($columns, $keyword) { |
|
65 | 65 | /** |
66 | 66 | * @var $where Builder |
67 | 67 | */ |
68 | - foreach($columns as $column) |
|
68 | + foreach ($columns as $column) |
|
69 | 69 | { |
70 | - if(strpos($column->getField(),".") === false) { |
|
70 | + if (strpos($column->getField(), ".") === false) { |
|
71 | 71 | $field = $this->data['table'].'.'.$column->getField(); |
72 | - }else{ |
|
72 | + } else { |
|
73 | 73 | $field = $column->getField(); |
74 | 74 | } |
75 | 75 | $where->orWhere($field, 'like', '%'.$keyword.'%'); |
@@ -82,36 +82,36 @@ discard block |
||
82 | 82 | /* |
83 | 83 | * This script to hanlde the callback inputed on this query method |
84 | 84 | */ |
85 | - if(isset($callback) && is_callable($callback)) { |
|
85 | + if (isset($callback) && is_callable($callback)) { |
|
86 | 86 | $query = call_user_func($callback, $query); |
87 | 87 | } |
88 | 88 | |
89 | - if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
89 | + if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
90 | 90 | $query = call_user_func($this->data['hook_index_query'], $query); |
91 | 91 | } |
92 | 92 | |
93 | 93 | |
94 | - if(request()->has(['order_by','order_sort'])) |
|
94 | + if (request()->has(['order_by', 'order_sort'])) |
|
95 | 95 | { |
96 | - $sort = (request("order_sort")=="asc")?"asc":"desc"; |
|
96 | + $sort = (request("order_sort") == "asc") ? "asc" : "desc"; |
|
97 | 97 | /* |
98 | 98 | * Check if order by contain "." it means {table}.{column} we have to parsing that |
99 | 99 | */ |
100 | - if(strpos(request("order_by"), ".")!==false) { |
|
101 | - $orderByTable = explode(".",request("order_by"))[0]; |
|
102 | - $orderByColumn = explode(".",request("order_by"))[1]; |
|
103 | - if(SchemaHelper::hasColumn($orderByTable, $orderByColumn)) { |
|
100 | + if (strpos(request("order_by"), ".") !== false) { |
|
101 | + $orderByTable = explode(".", request("order_by"))[0]; |
|
102 | + $orderByColumn = explode(".", request("order_by"))[1]; |
|
103 | + if (SchemaHelper::hasColumn($orderByTable, $orderByColumn)) { |
|
104 | 104 | $query->orderBy($orderByTable.".".$orderByColumn, $sort); |
105 | 105 | } |
106 | 106 | } else { |
107 | 107 | /* |
108 | 108 | * Check if order_by column in registered columns |
109 | 109 | */ |
110 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
110 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
111 | 111 | $query->orderBy(request('order_by'), request('order_sort')); |
112 | 112 | } |
113 | 113 | } |
114 | - }else{ |
|
114 | + } else { |
|
115 | 115 | /* |
116 | 116 | * For default, query will be order by primary key as descending |
117 | 117 | */ |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) { |
48 | 48 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
49 | 49 | } |
50 | - }else{ |
|
50 | + } else{ |
|
51 | 51 | $query->addSelect($column->getField()); |
52 | 52 | } |
53 | 53 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $keyword = sanitizeXSS(request("q")); |
61 | 61 | if(isset($this->data['hook_search_query'])) { |
62 | 62 | $query = call_user_func($this->data['hook_search_query'], $query); |
63 | - }else{ |
|
63 | + } else{ |
|
64 | 64 | $query->where(function ($where) use ($columns, $keyword) { |
65 | 65 | /** |
66 | 66 | * @var $where Builder |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | if(strpos($column->getField(),".") === false) { |
71 | 71 | $field = $this->data['table'].'.'.$column->getField(); |
72 | - }else{ |
|
72 | + } else{ |
|
73 | 73 | $field = $column->getField(); |
74 | 74 | } |
75 | 75 | $where->orWhere($field, 'like', '%'.$keyword.'%'); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $query->orderBy(request('order_by'), request('order_sort')); |
112 | 112 | } |
113 | 113 | } |
114 | - }else{ |
|
114 | + } else{ |
|
115 | 115 | /* |
116 | 116 | * For default, query will be order by primary key as descending |
117 | 117 | */ |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | $data = new TextModel(); |
66 | 66 | $data = $this->setDefaultModelValue($data); |
67 | 67 | $data->setLabel($label); |
68 | - $data->setName($this->name($label,$name)); |
|
69 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
68 | + $data->setName($this->name($label, $name)); |
|
69 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
70 | 70 | $data->setOrderByColumn($data->getField()); |
71 | 71 | $data->setType("text"); |
72 | 72 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | $data = new CheckboxModel(); |
83 | 83 | $data = $this->setDefaultModelValue($data); |
84 | 84 | $data->setLabel($label); |
85 | - $data->setName($this->name($label,$name)); |
|
86 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
85 | + $data->setName($this->name($label, $name)); |
|
86 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
87 | 87 | $data->setOrderByColumn($data->getField()); |
88 | 88 | $data->setType("checkbox"); |
89 | 89 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | $data = new PasswordModel(); |
100 | 100 | $data = $this->setDefaultModelValue($data); |
101 | 101 | $data->setLabel($label); |
102 | - $data->setName($this->name($label,$name)); |
|
103 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
102 | + $data->setName($this->name($label, $name)); |
|
103 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
104 | 104 | $data->setOrderByColumn($data->getField()); |
105 | 105 | $data->setType("password"); |
106 | 106 | $data->setShowDetail(false); |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | $data = new ImageModel(); |
119 | 119 | $data = $this->setDefaultModelValue($data); |
120 | 120 | $data->setLabel($label); |
121 | - $data->setName($this->name($label,$name)); |
|
122 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
121 | + $data->setName($this->name($label, $name)); |
|
122 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
123 | 123 | $data->setOrderByColumn($data->getField()); |
124 | 124 | $data->setType("image"); |
125 | 125 | |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | $data = new TextAreaModel(); |
136 | 136 | $data = $this->setDefaultModelValue($data); |
137 | 137 | $data->setLabel($label); |
138 | - $data->setName($this->name($label,$name)); |
|
139 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
138 | + $data->setName($this->name($label, $name)); |
|
139 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
140 | 140 | $data->setOrderByColumn($data->getField()); |
141 | 141 | $data->setType("text_area"); |
142 | 142 | |
@@ -147,20 +147,20 @@ discard block |
||
147 | 147 | |
148 | 148 | public function addSelectTable($label, $name = null, $selectConfig) |
149 | 149 | { |
150 | - if(isset($selectConfig['table']) && isset($selectConfig['value_option']) && isset($selectConfig['display_option'])) { |
|
150 | + if (isset($selectConfig['table']) && isset($selectConfig['value_option']) && isset($selectConfig['display_option'])) { |
|
151 | 151 | $this->index++; |
152 | 152 | |
153 | 153 | $data = new SelectTableModel(); |
154 | 154 | $data = $this->setDefaultModelValue($data); |
155 | 155 | $data->setLabel($label); |
156 | - $data->setName($this->name($label,$name)); |
|
156 | + $data->setName($this->name($label, $name)); |
|
157 | 157 | $data->setField($this->name($label, $name)); |
158 | 158 | $data->setType("select_table"); |
159 | 159 | $data->setOrderByColumn($selectConfig['table'].".".$selectConfig["display_option"]); |
160 | 160 | columnSingleton()->setColumn($this->index, $data); |
161 | 161 | |
162 | 162 | $selectTable = new SelectTable($this->index); |
163 | - $selectTable->optionsFromTable($selectConfig['table'],$selectConfig['value_option'],$selectConfig['display_option'],@$selectConfig['sql_condition']); |
|
163 | + $selectTable->optionsFromTable($selectConfig['table'], $selectConfig['value_option'], $selectConfig['display_option'], @$selectConfig['sql_condition']); |
|
164 | 164 | |
165 | 165 | return $selectTable; |
166 | 166 | } else { |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $data = new SelectOptionModel(); |
176 | 176 | $data = $this->setDefaultModelValue($data); |
177 | 177 | $data->setLabel($label); |
178 | - $data->setName($this->name($label,$name)); |
|
178 | + $data->setName($this->name($label, $name)); |
|
179 | 179 | $data->setField($this->name($label, $name)); |
180 | 180 | $data->setOrderByColumn($data->getField()); |
181 | 181 | $data->setType("select_option"); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | $selectOption = new SelectOption($this->index); |
186 | 186 | |
187 | - if($options) { |
|
187 | + if ($options) { |
|
188 | 188 | $selectOption->options($options); |
189 | 189 | } |
190 | 190 | |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | $data = new SelectQueryModel(); |
205 | 205 | $data = $this->setDefaultModelValue($data); |
206 | 206 | $data->setLabel($label); |
207 | - $data->setName($this->name($label,$name)); |
|
207 | + $data->setName($this->name($label, $name)); |
|
208 | 208 | $data->setField($this->name($label, $name)); |
209 | 209 | $data->setOrderByColumn($data->getField()); |
210 | 210 | $data->setType("select_query"); |
211 | 211 | |
212 | 212 | columnSingleton()->setColumn($this->index, $data); |
213 | 213 | |
214 | - $selectQuery =new SelectQuery($this->index); |
|
214 | + $selectQuery = new SelectQuery($this->index); |
|
215 | 215 | |
216 | - if($query) { |
|
216 | + if ($query) { |
|
217 | 217 | $selectQuery->optionsFromQuery($query); |
218 | 218 | } |
219 | 219 | |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | $data = new CustomModel(); |
229 | 229 | $data = $this->setDefaultModelValue($data); |
230 | 230 | $data->setLabel($label); |
231 | - $data->setName($this->name($label,$name)); |
|
232 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
231 | + $data->setName($this->name($label, $name)); |
|
232 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
233 | 233 | $data->setOrderByColumn($data->getField()); |
234 | 234 | $data->setType("custom"); |
235 | 235 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | $data = new DateModel(); |
246 | 246 | $data = $this->setDefaultModelValue($data); |
247 | 247 | $data->setLabel($label); |
248 | - $data->setName($this->name($label,$name)); |
|
249 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
248 | + $data->setName($this->name($label, $name)); |
|
249 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
250 | 250 | $data->setOrderByColumn($data->getField()); |
251 | 251 | $data->setType("date"); |
252 | 252 | |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | $data = new DatetimeModel(); |
263 | 263 | $data = $this->setDefaultModelValue($data); |
264 | 264 | $data->setLabel($label); |
265 | - $data->setName($this->name($label,$name)); |
|
266 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
265 | + $data->setName($this->name($label, $name)); |
|
266 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
267 | 267 | $data->setOrderByColumn($data->getField()); |
268 | 268 | $data->setType("datetime"); |
269 | 269 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | $data = new EmailModel(); |
280 | 280 | $data = $this->setDefaultModelValue($data); |
281 | 281 | $data->setLabel($label); |
282 | - $data->setName($this->name($label,$name)); |
|
283 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
282 | + $data->setName($this->name($label, $name)); |
|
283 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
284 | 284 | $data->setOrderByColumn($data->getField()); |
285 | 285 | $data->setType("email"); |
286 | 286 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | $data = new FileModel(); |
297 | 297 | $data = $this->setDefaultModelValue($data); |
298 | 298 | $data->setLabel($label); |
299 | - $data->setName($this->name($label,$name)); |
|
300 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
299 | + $data->setName($this->name($label, $name)); |
|
300 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
301 | 301 | $data->setOrderByColumn($data->getField()); |
302 | 302 | $data->setType("file"); |
303 | 303 | |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | $data = new HiddenModel(); |
315 | 315 | $data = $this->setDefaultModelValue($data); |
316 | 316 | $data->setLabel($label); |
317 | - $data->setName($this->name($label,$name)); |
|
318 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
317 | + $data->setName($this->name($label, $name)); |
|
318 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
319 | 319 | $data->setOrderByColumn($data->getField()); |
320 | 320 | $data->setType("hidden"); |
321 | 321 | |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | $data = new NumberModel(); |
332 | 332 | $data = $this->setDefaultModelValue($data); |
333 | 333 | $data->setLabel($label); |
334 | - $data->setName($this->name($label,$name)); |
|
335 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
334 | + $data->setName($this->name($label, $name)); |
|
335 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
336 | 336 | $data->setOrderByColumn($data->getField()); |
337 | 337 | $data->setType("number"); |
338 | 338 | |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | $data = new MoneyModel(); |
349 | 349 | $data = $this->setDefaultModelValue($data); |
350 | 350 | $data->setLabel($label); |
351 | - $data->setName($this->name($label,$name)); |
|
352 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
351 | + $data->setName($this->name($label, $name)); |
|
352 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
353 | 353 | $data->setOrderByColumn($data->getField()); |
354 | 354 | $data->setType("money"); |
355 | 355 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | $data = new RadioModel(); |
366 | 366 | $data = $this->setDefaultModelValue($data); |
367 | 367 | $data->setLabel($label); |
368 | - $data->setName($this->name($label,$name)); |
|
369 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
368 | + $data->setName($this->name($label, $name)); |
|
369 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
370 | 370 | $data->setOrderByColumn($data->getField()); |
371 | 371 | $data->setType("radio"); |
372 | 372 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | $data = new WysiwygModel(); |
383 | 383 | $data = $this->setDefaultModelValue($data); |
384 | 384 | $data->setLabel($label); |
385 | - $data->setName($this->name($label,$name)); |
|
386 | - $data->setField($field_to_save?:$this->name($label, $name)); |
|
385 | + $data->setName($this->name($label, $name)); |
|
386 | + $data->setField($field_to_save ?: $this->name($label, $name)); |
|
387 | 387 | $data->setOrderByColumn($data->getField()); |
388 | 388 | $data->setType("wysiwyg"); |
389 | 389 |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | |
25 | 25 | public function getIndex() { |
26 | 26 | $data = []; |
27 | - return view($this->view.".index",$data); |
|
27 | + return view($this->view.".index", $data); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function postSave() |
31 | 31 | { |
32 | - if(!isConfigCached()) { |
|
32 | + if (!isConfigCached()) { |
|
33 | 33 | setEnvironmentValue([ |
34 | 34 | "APP_DEBUG"=>request("APP_DEBUG") |
35 | 35 | ]); |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | putSetting("AUTO_REDIRECT_TO_LOGIN", request("AUTO_REDIRECT_TO_LOGIN")); |
42 | 42 | putSetting("LOGIN_NOTIFICATION", request("LOGIN_NOTIFICATION")); |
43 | 43 | |
44 | - if(request("htaccess_ServerSignature")) { |
|
44 | + if (request("htaccess_ServerSignature")) { |
|
45 | 45 | putHtaccess("ServerSignature Off"); |
46 | 46 | } |
47 | 47 | |
48 | - if(request("htaccess_IndexIgnore")) { |
|
48 | + if (request("htaccess_IndexIgnore")) { |
|
49 | 49 | putHtaccess("IndexIgnore *"); |
50 | 50 | } |
51 | 51 | |
52 | - if(request("htaccess_dotAccess")) { |
|
52 | + if (request("htaccess_dotAccess")) { |
|
53 | 53 | putHtaccess(" |
54 | 54 | <FilesMatch \"^\.\"> |
55 | 55 | Order allow,deny |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | </FilesMatch>"); |
58 | 58 | } |
59 | 59 | |
60 | - if(request("htaccess_preventVendor")) { |
|
60 | + if (request("htaccess_preventVendor")) { |
|
61 | 61 | putHtaccess("RewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]"); |
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | - return cb()->redirectBack("Security has been updated!","success"); |
|
65 | + return cb()->redirectBack("Security has been updated!", "success"); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | \ No newline at end of file |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | // Register views |
27 | 27 | $this->loadViewsFrom(__DIR__.'/views', 'crudbooster'); |
28 | 28 | $this->loadViewsFrom(__DIR__.'/types', 'types'); |
29 | - $this->loadTranslationsFrom(__DIR__."/localization","cb"); |
|
29 | + $this->loadTranslationsFrom(__DIR__."/localization", "cb"); |
|
30 | 30 | |
31 | 31 | // Publish the files |
32 | - $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')],'cb_config'); |
|
33 | - $this->publishes([__DIR__.'/database' => base_path('database')],'cb_migration'); |
|
34 | - $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')],'cb_hook'); |
|
35 | - $this->publishes([__DIR__ . '/assets' =>public_path('cb_asset')],'cb_asset'); |
|
32 | + $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')], 'cb_config'); |
|
33 | + $this->publishes([__DIR__.'/database' => base_path('database')], 'cb_migration'); |
|
34 | + $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')], 'cb_hook'); |
|
35 | + $this->publishes([__DIR__.'/assets' =>public_path('cb_asset')], 'cb_asset'); |
|
36 | 36 | |
37 | 37 | // Override Local FileSystem |
38 | 38 | Config::set("filesystems.disks.local.root", cbConfig("LOCAL_FILESYSTEM_PATH", public_path("storage"))); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | require __DIR__.'/helpers/Helper.php'; |
55 | 55 | |
56 | 56 | // Singletons |
57 | - $this->app->singleton('crudbooster', function () |
|
57 | + $this->app->singleton('crudbooster', function() |
|
58 | 58 | { |
59 | 59 | return true; |
60 | 60 | }); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | // Merging configuration |
80 | - $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php','crudbooster'); |
|
80 | + $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster'); |
|
81 | 81 | |
82 | 82 | // Register additional library |
83 | 83 | $this->app->register('Intervention\Image\ImageServiceProvider'); |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | |
89 | 89 | private function registerPlugin() |
90 | 90 | { |
91 | - if(file_exists(app_path("CBPlugins"))) { |
|
91 | + if (file_exists(app_path("CBPlugins"))) { |
|
92 | 92 | $views = scandir(app_path("CBPlugins")); |
93 | - foreach($views as $view) { |
|
94 | - if($view != "." && $view != "..") { |
|
93 | + foreach ($views as $view) { |
|
94 | + if ($view != "." && $view != "..") { |
|
95 | 95 | $basename = basename($view); |
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 | // register route |
99 | 99 | require app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Routes".DIRECTORY_SEPARATOR."Route.php"); |
100 | 100 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | private function registerTypeRoutes() { |
108 | 108 | $routes = rglob(__DIR__.DIRECTORY_SEPARATOR."types".DIRECTORY_SEPARATOR."Route.php"); |
109 | - foreach($routes as $route) { |
|
109 | + foreach ($routes as $route) { |
|
110 | 110 | require $route; |
111 | 111 | } |
112 | 112 | } |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | |
29 | 29 | public function getIndex() { |
30 | 30 | |
31 | - if(request("refresh")) { |
|
32 | - $this->fetchPluginData(false ); |
|
33 | - return cb()->redirectBack("Plugin list has been refreshed!","success"); |
|
31 | + if (request("refresh")) { |
|
32 | + $this->fetchPluginData(false); |
|
33 | + return cb()->redirectBack("Plugin list has been refreshed!", "success"); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $data = []; |
37 | 37 | $data['result'] = $this->fetchPluginData(); |
38 | - return view($this->view.'.index',$data); |
|
38 | + return view($this->view.'.index', $data); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function postLoginAccount() { |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | ]); |
51 | 51 | $response = $curl->send(); |
52 | 52 | |
53 | - if($respArray = json_decode($response, true)) { |
|
54 | - if($respArray['status'] && isset($respArray['token'])) { |
|
53 | + if ($respArray = json_decode($response, true)) { |
|
54 | + if ($respArray['status'] && isset($respArray['token'])) { |
|
55 | 55 | session(['account_token'=>$respArray['token']]); |
56 | 56 | } |
57 | - return response()->make($response,200,["Content-Type"=>"application/json"]); |
|
57 | + return response()->make($response, 200, ["Content-Type"=>"application/json"]); |
|
58 | 58 | } else { |
59 | - return response()->json(['status'=>false,'message'=>'failed']); |
|
59 | + return response()->json(['status'=>false, 'message'=>'failed']); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | ]); |
74 | 74 | $response = $curl->send(); |
75 | 75 | |
76 | - if($respArray = json_decode($response, true)) { |
|
77 | - if($respArray['status']) { |
|
76 | + if ($respArray = json_decode($response, true)) { |
|
77 | + if ($respArray['status']) { |
|
78 | 78 | $form = base64_decode($respArray['payment']); |
79 | - return response()->json(['status'=>true,'form'=>$form]); |
|
79 | + return response()->json(['status'=>true, 'form'=>$form]); |
|
80 | 80 | } else { |
81 | 81 | return response()->json($respArray); |
82 | 82 | } |
83 | 83 | } else { |
84 | - return response()->json(['status'=>false,'message'=>'failed','raw'=>$response]); |
|
84 | + return response()->json(['status'=>false, 'message'=>'failed', 'raw'=>$response]); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -89,28 +89,28 @@ discard block |
||
89 | 89 | { |
90 | 90 | $pluginData = $this->fetchPluginData(); |
91 | 91 | |
92 | - if(isset($pluginData[$key])) { |
|
93 | - if(file_exists(app_path("CBPlugins/".$key))) { |
|
92 | + if (isset($pluginData[$key])) { |
|
93 | + if (file_exists(app_path("CBPlugins/".$key))) { |
|
94 | 94 | rrmdir(app_path("CBPlugins/".$key)); |
95 | 95 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
96 | - }else{ |
|
97 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
|
96 | + } else { |
|
97 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']); |
|
98 | 98 | } |
99 | - }else { |
|
100 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
|
99 | + } else { |
|
100 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - private function recursiveCopy($src,$dst) { |
|
104 | + private function recursiveCopy($src, $dst) { |
|
105 | 105 | $dir = opendir($src); |
106 | 106 | @mkdir($dst); |
107 | - while(false !== ( $file = readdir($dir)) ) { |
|
108 | - if (( $file != '.' ) && ( $file != '..' )) { |
|
109 | - if ( is_dir($src . '/' . $file) ) { |
|
110 | - $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
|
107 | + while (false !== ($file = readdir($dir))) { |
|
108 | + if (($file != '.') && ($file != '..')) { |
|
109 | + if (is_dir($src.'/'.$file)) { |
|
110 | + $this->recursiveCopy($src.'/'.$file, $dst.'/'.$file); |
|
111 | 111 | } |
112 | 112 | else { |
113 | - copy($src . '/' . $file,$dst . '/' . $file); |
|
113 | + copy($src.'/'.$file, $dst.'/'.$file); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $pluginData = $this->fetchPluginData(); |
123 | 123 | |
124 | 124 | try { |
125 | - if(isset($pluginData[$key])) { |
|
125 | + if (isset($pluginData[$key])) { |
|
126 | 126 | $plugin = $pluginData[$key]; |
127 | 127 | |
128 | 128 | // Create temp file of zip plugin |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | fclose($temp); |
141 | 141 | |
142 | 142 | // Rename |
143 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
143 | + if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
144 | 144 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
145 | 145 | |
146 | 146 | // Read Plugin JSON |
147 | 147 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$key."/plugin.json")), true); |
148 | 148 | |
149 | 149 | // Check if has asset |
150 | - if($pluginJson && $pluginJson['asset']) { |
|
150 | + if ($pluginJson && $pluginJson['asset']) { |
|
151 | 151 | // Check destination folder is ready |
152 | - if(file_exists(public_path("cb_asset/".$key))) { |
|
152 | + if (file_exists(public_path("cb_asset/".$key))) { |
|
153 | 153 | rrmdir(public_path("cb_asset/".$key)); |
154 | 154 | } |
155 | 155 | |
@@ -160,22 +160,22 @@ discard block |
||
160 | 160 | $this->recursiveCopy(app_path("CBPlugins/".$key."/".$pluginJson['asset']), public_path("cb_asset/".$key)); |
161 | 161 | } |
162 | 162 | |
163 | - return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']); |
|
163 | + return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']); |
|
164 | 164 | |
165 | 165 | } else { |
166 | - return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
166 | + return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
167 | 167 | } |
168 | - }else{ |
|
169 | - return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
|
168 | + } else { |
|
169 | + return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']); |
|
170 | 170 | } |
171 | 171 | } catch (\Exception $e) { |
172 | - return response()->json(['status'=>false,'message'=>'Something went wrong!']); |
|
172 | + return response()->json(['status'=>false, 'message'=>'Something went wrong!']); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | 176 | private function fetchPluginData($cache = true) |
177 | 177 | { |
178 | - if($cache === true && $data = Cache::get("plugin_store_data")) { |
|
178 | + if ($cache === true && $data = Cache::get("plugin_store_data")) { |
|
179 | 179 | return $data; |
180 | 180 | } |
181 | 181 | |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | $context = stream_context_create($opts); |
193 | 193 | $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context); |
194 | 194 | |
195 | - if($data) { |
|
195 | + if ($data) { |
|
196 | 196 | $data = json_decode($data, true); |
197 | - if($data['status']==true) { |
|
197 | + if ($data['status'] == true) { |
|
198 | 198 | |
199 | - foreach($data['data'] as $item) { |
|
199 | + foreach ($data['data'] as $item) { |
|
200 | 200 | $key = $item['key']; |
201 | - $result[ $key ] = $item; |
|
201 | + $result[$key] = $item; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | $result = collect($result)->sortBy("name")->all(); |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | if(file_exists(app_path("CBPlugins/".$key))) { |
94 | 94 | rrmdir(app_path("CBPlugins/".$key)); |
95 | 95 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
96 | - }else{ |
|
96 | + } else{ |
|
97 | 97 | return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
98 | 98 | } |
99 | - }else { |
|
99 | + } else { |
|
100 | 100 | return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
101 | 101 | } |
102 | 102 | } |
@@ -108,8 +108,7 @@ discard block |
||
108 | 108 | if (( $file != '.' ) && ( $file != '..' )) { |
109 | 109 | if ( is_dir($src . '/' . $file) ) { |
110 | 110 | $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
111 | - } |
|
112 | - else { |
|
111 | + } else { |
|
113 | 112 | copy($src . '/' . $file,$dst . '/' . $file); |
114 | 113 | } |
115 | 114 | } |
@@ -140,7 +139,9 @@ discard block |
||
140 | 139 | fclose($temp); |
141 | 140 | |
142 | 141 | // Rename |
143 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
142 | + if(file_exists(app_path("CBPlugins/".$key))) { |
|
143 | + rrmdir(app_path("CBPlugins/".$key)); |
|
144 | + } |
|
144 | 145 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
145 | 146 | |
146 | 147 | // Read Plugin JSON |
@@ -165,7 +166,7 @@ discard block |
||
165 | 166 | } else { |
166 | 167 | return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]); |
167 | 168 | } |
168 | - }else{ |
|
169 | + } else{ |
|
169 | 170 | return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
170 | 171 | } |
171 | 172 | } catch (\Exception $e) { |