@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | /* |
| 32 | 32 | * For security reason we have limit the upload file formats bellow |
| 33 | 33 | */ |
| 34 | - 'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif','pdf','xls','xlsx','doc','docx','txt','zip','rar','rtf'], |
|
| 34 | + 'UPLOAD_FILE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif', 'pdf', 'xls', 'xlsx', 'doc', 'docx', 'txt', 'zip', 'rar', 'rtf'], |
|
| 35 | 35 | |
| 36 | - 'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg','jpeg','png','gif'], |
|
| 36 | + 'UPLOAD_IMAGE_EXTENSION_ALLOWED' => ['jpg', 'jpeg', 'png', 'gif'], |
|
| 37 | 37 | |
| 38 | 38 | /* |
| 39 | 39 | * Override Local FileSystem From Storage To Another |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * You can define in this array what the tables you want to include in "php artisan crudbooster:data_migration" |
| 70 | 70 | * The default is all cb_ prefix will be include in data migration |
| 71 | 71 | */ |
| 72 | - 'ADDITIONAL_DATA_MIGRATION'=>['users','migrations'], |
|
| 72 | + 'ADDITIONAL_DATA_MIGRATION'=>['users', 'migrations'], |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | /* |
@@ -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(cbConfig("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 | |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 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 | } |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 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 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 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 | } |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function __call($method, $parameters) |
| 29 | 29 | { |
| 30 | - if($method == "getData") { |
|
| 30 | + if ($method == "getData") { |
|
| 31 | 31 | $key = $parameters[0]; |
| 32 | - if(isset($this->data[$key])) { |
|
| 32 | + if (isset($this->data[$key])) { |
|
| 33 | 33 | return $this->data[$key]; |
| 34 | - }else{ |
|
| 34 | + } else { |
|
| 35 | 35 | return null; |
| 36 | 36 | } |
| 37 | - }else{ |
|
| 37 | + } else { |
|
| 38 | 38 | return null; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
| 50 | 50 | |
| 51 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
| 52 | - if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
| 51 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
| 52 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
| 53 | 53 | $query->whereNull($this->data['table'].'.deleted_at'); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if(isset($joins)) { |
|
| 57 | - foreach($joins as $join) |
|
| 56 | + if (isset($joins)) { |
|
| 57 | + foreach ($joins as $join) |
|
| 58 | 58 | { |
| 59 | 59 | $query->join($join['target_table'], |
| 60 | 60 | $join['target_table_primary'], |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - foreach($columns as $column) { |
|
| 67 | + foreach ($columns as $column) { |
|
| 68 | 68 | /** @var ColumnModel $column */ |
| 69 | - if($column->getType() != "custom") { |
|
| 70 | - if(strpos($column->getField(),".") === false) { |
|
| 71 | - if(Schema::hasColumn($this->data['table'], $column->getField())) { |
|
| 69 | + if ($column->getType() != "custom") { |
|
| 70 | + if (strpos($column->getField(), ".") === false) { |
|
| 71 | + if (Schema::hasColumn($this->data['table'], $column->getField())) { |
|
| 72 | 72 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
| 73 | 73 | } |
| 74 | - }else{ |
|
| 74 | + } else { |
|
| 75 | 75 | $query->addSelect($column->getField()); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -79,20 +79,20 @@ discard block |
||
| 79 | 79 | $query = getTypeHook($column->getType())->query($query, $column); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if(request()->has('q')) |
|
| 82 | + if (request()->has('q')) |
|
| 83 | 83 | { |
| 84 | - if(isset($this->data['hook_search_query'])) { |
|
| 84 | + if (isset($this->data['hook_search_query'])) { |
|
| 85 | 85 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 86 | - }else{ |
|
| 87 | - $query->where(function ($where) use ($columns) { |
|
| 86 | + } else { |
|
| 87 | + $query->where(function($where) use ($columns) { |
|
| 88 | 88 | /** |
| 89 | 89 | * @var $where Builder |
| 90 | 90 | */ |
| 91 | - foreach($columns as $column) |
|
| 91 | + foreach ($columns as $column) |
|
| 92 | 92 | { |
| 93 | - if(strpos($column->getField(),".") === false) { |
|
| 93 | + if (strpos($column->getField(), ".") === false) { |
|
| 94 | 94 | $field = $this->data['table'].'.'.$column->getField(); |
| 95 | - }else{ |
|
| 95 | + } else { |
|
| 96 | 96 | $field = $column->getField(); |
| 97 | 97 | } |
| 98 | 98 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
| 104 | + if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
| 105 | 105 | $query = call_user_func($this->data['hook_index_query'], $query); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
| 109 | - if(request()->has(['order_by','order_sort'])) |
|
| 109 | + if (request()->has(['order_by', 'order_sort'])) |
|
| 110 | 110 | { |
| 111 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
| 111 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
| 112 | 112 | $query->orderBy(request('order_by'), request('order_sort')); |
| 113 | 113 | } |
| 114 | - }else{ |
|
| 114 | + } else { |
|
| 115 | 115 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | public function getIndex() |
| 122 | 122 | { |
| 123 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 123 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 124 | 124 | |
| 125 | 125 | $query = $this->repository(); |
| 126 | - $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
|
| 126 | + $result = $query->paginate(request("limit") ?: cbConfig("LIMIT_TABLE_DATA")); |
|
| 127 | 127 | $data['result'] = $result; |
| 128 | 128 | |
| 129 | 129 | return view("crudbooster::module.index.index", array_merge($data, $this->data)); |
@@ -135,29 +135,29 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | private function validation() |
| 137 | 137 | { |
| 138 | - if(isset($this->data['validation'])) { |
|
| 138 | + if (isset($this->data['validation'])) { |
|
| 139 | 139 | $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']); |
| 140 | 140 | if ($validator->fails()) { |
| 141 | 141 | $message = $validator->messages(); |
| 142 | 142 | $message_all = $message->all(); |
| 143 | - throw new CBValidationException(implode(', ',$message_all)); |
|
| 143 | + throw new CBValidationException(implode(', ', $message_all)); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | public function getAdd() |
| 149 | 149 | { |
| 150 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 150 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 151 | 151 | |
| 152 | 152 | $data = []; |
| 153 | 153 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
| 154 | 154 | $data['action_url'] = module()->addSaveURL(); |
| 155 | - return view('crudbooster::module.form.form',array_merge($data, $this->data)); |
|
| 155 | + return view('crudbooster::module.form.form', array_merge($data, $this->data)); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | public function postAddSave() |
| 159 | 159 | { |
| 160 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 160 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 161 | 161 | |
| 162 | 162 | try { |
| 163 | 163 | $this->validation(); |
@@ -165,35 +165,35 @@ discard block |
||
| 165 | 165 | $data = columnSingleton()->getAssignmentData(); |
| 166 | 166 | |
| 167 | 167 | //Clear data from Primary Key |
| 168 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
| 168 | + unset($data[cb()->pk($this->data['table'])]); |
|
| 169 | 169 | |
| 170 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
| 170 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
| 171 | 171 | $data['created_at'] = date('Y-m-d H:i:s'); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 174 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 175 | 175 | $data['updated_at'] = date('Y-m-d H:i:s'); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if(isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
| 178 | + if (isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
| 179 | 179 | $data = call_user_func($this->data['hook_before_insert'], $data); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $id = DB::table($this->data['table'])->insertGetId($data); |
| 183 | 183 | |
| 184 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
| 184 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
| 185 | 185 | call_user_func($this->data['hook_after_insert'], $id); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | } catch (CBValidationException $e) { |
| 189 | 189 | Log::debug($e); |
| 190 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
| 190 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
| 191 | 191 | } catch (\Exception $e) { |
| 192 | 192 | Log::error($e); |
| 193 | - return cb()->redirectBack(cbLang("something_went_wrong"),'warning'); |
|
| 193 | + return cb()->redirectBack(cbLang("something_went_wrong"), 'warning'); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if (Str::contains(request("submit"),cbLang("more"))) { |
|
| 196 | + if (Str::contains(request("submit"), cbLang("more"))) { |
|
| 197 | 197 | return cb()->redirect(module()->addURL(), cbLang("the_data_has_been_added"), 'success'); |
| 198 | 198 | } else { |
| 199 | 199 | return cb()->redirect(module()->url(), cbLang("the_data_has_been_added"), 'success'); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | public function getEdit($id) |
| 204 | 204 | { |
| 205 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 205 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 206 | 206 | |
| 207 | 207 | $data = []; |
| 208 | 208 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | public function postEditSave($id) |
| 215 | 215 | { |
| 216 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 216 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 217 | 217 | |
| 218 | 218 | try { |
| 219 | 219 | $this->validation(); |
@@ -221,51 +221,51 @@ discard block |
||
| 221 | 221 | $data = columnSingleton()->getAssignmentData(); |
| 222 | 222 | |
| 223 | 223 | // Make sure the Primary Key is not included |
| 224 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
| 224 | + unset($data[cb()->pk($this->data['table'])]); |
|
| 225 | 225 | |
| 226 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 226 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 227 | 227 | $data['updated_at'] = date('Y-m-d H:i:s'); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | unset($data['created_at']); |
| 231 | 231 | |
| 232 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
| 232 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
| 233 | 233 | $data = call_user_func($this->data['hook_before_update'], $id, $data); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | cb()->update($this->data['table'], $id, $data); |
| 237 | 237 | |
| 238 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
| 238 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
| 239 | 239 | call_user_func($this->data['hook_after_update'], $id); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | } catch (CBValidationException $e) { |
| 243 | 243 | Log::debug($e); |
| 244 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
| 244 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
| 245 | 245 | } catch (\Exception $e) { |
| 246 | 246 | Log::error($e); |
| 247 | - return cb()->redirectBack(cbLang("something_went_wrong"),'warning'); |
|
| 247 | + return cb()->redirectBack(cbLang("something_went_wrong"), 'warning'); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | if (Str::contains(request("submit"), cbLang("more"))) { |
| 252 | - return cb()->redirectBack( cbLang("the_data_has_been_updated"), 'success'); |
|
| 252 | + return cb()->redirectBack(cbLang("the_data_has_been_updated"), 'success'); |
|
| 253 | 253 | } else { |
| 254 | - return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success'); |
|
| 254 | + return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success'); |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | public function getDelete($id) |
| 259 | 259 | { |
| 260 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 260 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 261 | 261 | |
| 262 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
| 262 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
| 263 | 263 | call_user_func($this->data['hook_before_delete'], $id); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
| 266 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
| 267 | 267 | |
| 268 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
| 268 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
| 269 | 269 | DB::table($this->data['table']) |
| 270 | 270 | ->where(getPrimaryKey($this->data['table']), $id) |
| 271 | 271 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -275,16 +275,16 @@ discard block |
||
| 275 | 275 | ->delete(); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
| 278 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
| 279 | 279 | call_user_func($this->data['hook_after_delete'], $id); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - return cb()->redirectBack( cbLang("the_data_has_been_deleted"), 'success'); |
|
| 282 | + return cb()->redirectBack(cbLang("the_data_has_been_deleted"), 'success'); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | public function getDetail($id) |
| 286 | 286 | { |
| 287 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 287 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 288 | 288 | |
| 289 | 289 | $data = []; |
| 290 | 290 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | $key = $parameters[0]; |
| 32 | 32 | if(isset($this->data[$key])) { |
| 33 | 33 | return $this->data[$key]; |
| 34 | - }else{ |
|
| 34 | + } else{ |
|
| 35 | 35 | return null; |
| 36 | 36 | } |
| 37 | - }else{ |
|
| 37 | + } else{ |
|
| 38 | 38 | return null; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if(Schema::hasColumn($this->data['table'], $column->getField())) { |
| 72 | 72 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
| 73 | 73 | } |
| 74 | - }else{ |
|
| 74 | + } else{ |
|
| 75 | 75 | $query->addSelect($column->getField()); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | if(isset($this->data['hook_search_query'])) { |
| 85 | 85 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 86 | - }else{ |
|
| 86 | + } else{ |
|
| 87 | 87 | $query->where(function ($where) use ($columns) { |
| 88 | 88 | /** |
| 89 | 89 | * @var $where Builder |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | if(strpos($column->getField(),".") === false) { |
| 94 | 94 | $field = $this->data['table'].'.'.$column->getField(); |
| 95 | - }else{ |
|
| 95 | + } else{ |
|
| 96 | 96 | $field = $column->getField(); |
| 97 | 97 | } |
| 98 | 98 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
| 112 | 112 | $query->orderBy(request('order_by'), request('order_sort')); |
| 113 | 113 | } |
| 114 | - }else{ |
|
| 114 | + } else{ |
|
| 115 | 115 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -120,7 +120,9 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | public function getIndex() |
| 122 | 122 | { |
| 123 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 123 | + if(!module()->canBrowse()) { |
|
| 124 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 125 | + } |
|
| 124 | 126 | |
| 125 | 127 | $query = $this->repository(); |
| 126 | 128 | $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
@@ -147,7 +149,9 @@ discard block |
||
| 147 | 149 | |
| 148 | 150 | public function getAdd() |
| 149 | 151 | { |
| 150 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 152 | + if(!module()->canCreate()) { |
|
| 153 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 154 | + } |
|
| 151 | 155 | |
| 152 | 156 | $data = []; |
| 153 | 157 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
@@ -157,7 +161,9 @@ discard block |
||
| 157 | 161 | |
| 158 | 162 | public function postAddSave() |
| 159 | 163 | { |
| 160 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 164 | + if(!module()->canCreate()) { |
|
| 165 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 166 | + } |
|
| 161 | 167 | |
| 162 | 168 | try { |
| 163 | 169 | $this->validation(); |
@@ -202,7 +208,9 @@ discard block |
||
| 202 | 208 | |
| 203 | 209 | public function getEdit($id) |
| 204 | 210 | { |
| 205 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 211 | + if(!module()->canUpdate()) { |
|
| 212 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 213 | + } |
|
| 206 | 214 | |
| 207 | 215 | $data = []; |
| 208 | 216 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -213,7 +221,9 @@ discard block |
||
| 213 | 221 | |
| 214 | 222 | public function postEditSave($id) |
| 215 | 223 | { |
| 216 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 224 | + if(!module()->canUpdate()) { |
|
| 225 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 226 | + } |
|
| 217 | 227 | |
| 218 | 228 | try { |
| 219 | 229 | $this->validation(); |
@@ -257,7 +267,9 @@ discard block |
||
| 257 | 267 | |
| 258 | 268 | public function getDelete($id) |
| 259 | 269 | { |
| 260 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 270 | + if(!module()->canDelete()) { |
|
| 271 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 272 | + } |
|
| 261 | 273 | |
| 262 | 274 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
| 263 | 275 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -284,7 +296,9 @@ discard block |
||
| 284 | 296 | |
| 285 | 297 | public function getDetail($id) |
| 286 | 298 | { |
| 287 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 299 | + if(!module()->canRead()) { |
|
| 300 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 301 | + } |
|
| 288 | 302 | |
| 289 | 303 | $data = []; |
| 290 | 304 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | public function getLogin() |
| 10 | 10 | { |
| 11 | - if(!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
| 11 | + if (!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
| 12 | 12 | |
| 13 | 13 | cbHook()->hookGetLogin(); |
| 14 | 14 | |
@@ -17,20 +17,20 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public function postLogin() |
| 19 | 19 | { |
| 20 | - try{ |
|
| 20 | + try { |
|
| 21 | 21 | cb()->validation([ |
| 22 | 22 | 'email'=>'required|email', |
| 23 | 23 | 'password'=>'required' |
| 24 | 24 | ]); |
| 25 | - $credential = request()->only(['email','password']); |
|
| 25 | + $credential = request()->only(['email', 'password']); |
|
| 26 | 26 | if (auth()->attempt($credential)) { |
| 27 | 27 | cbHook()->hookPostLogin(); |
| 28 | 28 | return redirect(cb()->getAdminUrl()); |
| 29 | 29 | } else { |
| 30 | - return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']); |
|
| 30 | + return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'), 'message_type'=>'warning']); |
|
| 31 | 31 | } |
| 32 | - }catch (CBValidationException $e) { |
|
| 33 | - return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
|
| 32 | + } catch (CBValidationException $e) { |
|
| 33 | + return cb()->redirect(cb()->getAdminUrl("login"), $e->getMessage(), 'warning'); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -45,25 +45,25 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function postLoginDeveloper() { |
| 48 | - try{ |
|
| 48 | + try { |
|
| 49 | 49 | cb()->validation([ |
| 50 | 50 | 'username'=>'required', |
| 51 | 51 | 'password'=>'required' |
| 52 | 52 | ]); |
| 53 | 53 | |
| 54 | - if(request('username') == getSetting('developer_username') |
|
| 54 | + if (request('username') == getSetting('developer_username') |
|
| 55 | 55 | && request('password') == getSetting("developer_password")) { |
| 56 | 56 | |
| 57 | 57 | session(['developer'=>getSetting('developer_username')]); |
| 58 | 58 | |
| 59 | 59 | return redirect(cb()->getDeveloperUrl()); |
| 60 | 60 | |
| 61 | - }else{ |
|
| 62 | - return cb()->redirectBack( cbLang("password_and_username_is_wrong")); |
|
| 61 | + } else { |
|
| 62 | + return cb()->redirectBack(cbLang("password_and_username_is_wrong")); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - }catch (CBValidationException $e) { |
|
| 66 | - return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning'); |
|
| 65 | + } catch (CBValidationException $e) { |
|
| 66 | + return cb()->redirect(cb()->getLoginUrl(), $e->getMessage(), 'warning'); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | public function getLogin() |
| 10 | 10 | { |
| 11 | - if(!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
| 11 | + if(!auth()->guest()) { |
|
| 12 | + return redirect(cb()->getAdminUrl()); |
|
| 13 | + } |
|
| 12 | 14 | |
| 13 | 15 | cbHook()->hookGetLogin(); |
| 14 | 16 | |
@@ -29,7 +31,7 @@ discard block |
||
| 29 | 31 | } else { |
| 30 | 32 | return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']); |
| 31 | 33 | } |
| 32 | - }catch (CBValidationException $e) { |
|
| 34 | + } catch (CBValidationException $e) { |
|
| 33 | 35 | return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
| 34 | 36 | } |
| 35 | 37 | } |
@@ -58,11 +60,11 @@ discard block |
||
| 58 | 60 | |
| 59 | 61 | return redirect(cb()->getDeveloperUrl()); |
| 60 | 62 | |
| 61 | - }else{ |
|
| 63 | + } else{ |
|
| 62 | 64 | return cb()->redirectBack( cbLang("password_and_username_is_wrong")); |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | - }catch (CBValidationException $e) { |
|
| 67 | + } catch (CBValidationException $e) { |
|
| 66 | 68 | return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning'); |
| 67 | 69 | } |
| 68 | 70 | } |
@@ -18,8 +18,8 @@ |
||
| 18 | 18 | public function handle($request, Closure $next) |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - if(session()->get("developer") != getSetting('developer_username')) { |
|
| 22 | - return cb()->redirect(cb()->getDeveloperUrl("login"),"Please login for first"); |
|
| 21 | + if (session()->get("developer") != getSetting('developer_username')) { |
|
| 22 | + return cb()->redirect(cb()->getDeveloperUrl("login"), "Please login for first"); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | return $next($request); |
@@ -25,15 +25,15 @@ |
||
| 25 | 25 | { |
| 26 | 26 | |
| 27 | 27 | try { |
| 28 | - if(@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) { |
|
| 28 | + if (@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) { |
|
| 29 | 29 | $password = Str::random(16); |
| 30 | - }else{ |
|
| 30 | + } else { |
|
| 31 | 31 | $password = $this->command->option("password"); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if(@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) { |
|
| 34 | + if (@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) { |
|
| 35 | 35 | $username = Str::random(5); |
| 36 | - }else{ |
|
| 36 | + } else { |
|
| 37 | 37 | $username = $this->command->option("username"); |
| 38 | 38 | } |
| 39 | 39 | } catch (\Exception $e) { |
@@ -27,13 +27,13 @@ |
||
| 27 | 27 | try { |
| 28 | 28 | if(@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) { |
| 29 | 29 | $password = Str::random(16); |
| 30 | - }else{ |
|
| 30 | + } else{ |
|
| 31 | 31 | $password = $this->command->option("password"); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | if(@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) { |
| 35 | 35 | $username = Str::random(5); |
| 36 | - }else{ |
|
| 36 | + } else{ |
|
| 37 | 37 | $username = $this->command->option("username"); |
| 38 | 38 | } |
| 39 | 39 | } catch (\Exception $e) { |
@@ -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 | }); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Merging configuration |
| 74 | - $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php','crudbooster'); |
|
| 74 | + $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster'); |
|
| 75 | 75 | |
| 76 | 76 | // Register additional library |
| 77 | 77 | $this->app->register('Intervention\Image\ImageServiceProvider'); |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | private function registerPlugin() |
| 84 | 84 | { |
| 85 | 85 | $views = scandir(app_path("CBPlugins")); |
| 86 | - foreach($views as $view) { |
|
| 87 | - if($view != "." && $view != "..") { |
|
| 86 | + foreach ($views as $view) { |
|
| 87 | + if ($view != "." && $view != "..") { |
|
| 88 | 88 | $basename = basename($view); |
| 89 | 89 | // register view |
| 90 | - $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"),$basename); |
|
| 90 | + $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"), $basename); |
|
| 91 | 91 | // register route |
| 92 | 92 | require app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Routes".DIRECTORY_SEPARATOR."Route.php"); |
| 93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | private function registerTypeRoutes() { |
| 98 | 98 | $routes = rglob(__DIR__.DIRECTORY_SEPARATOR."types".DIRECTORY_SEPARATOR."Route.php"); |
| 99 | - foreach($routes as $route) { |
|
| 99 | + foreach ($routes as $route) { |
|
| 100 | 100 | require $route; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -15,26 +15,26 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public static function has($key) |
| 17 | 17 | { |
| 18 | - if(file_exists(app_path("CBPlugins/".$key))) return true; |
|
| 18 | + if (file_exists(app_path("CBPlugins/".$key))) return true; |
|
| 19 | 19 | else return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public static function isNeedUpgrade($pluginKey, $versionToCompare) |
| 23 | 23 | { |
| 24 | 24 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$pluginKey."/plugin.json")), true); |
| 25 | - if($pluginJson) { |
|
| 26 | - return version_compare($pluginJson['version'], $versionToCompare,"!="); |
|
| 27 | - }else{ |
|
| 25 | + if ($pluginJson) { |
|
| 26 | + return version_compare($pluginJson['version'], $versionToCompare, "!="); |
|
| 27 | + } else { |
|
| 28 | 28 | return false; |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public static function registerDefaultRoute($dir) |
| 33 | 33 | { |
| 34 | - Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
| 34 | + Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
| 35 | 35 | 'prefix'=>"developer/".getSetting('developer_path'), |
| 36 | - 'namespace' => 'App\CBPlugins\\'.basename(dirname("./../".$dir)).'\Controllers'], function () use ($dir) { |
|
| 37 | - cb()->routeController("plugins/".basename(dirname("./../".$dir)),"\App\CBPlugins\\".basename(dirname("./../".$dir))."\Controllers\\".basename(dirname("./../".$dir))."Controller"); |
|
| 36 | + 'namespace' => 'App\CBPlugins\\'.basename(dirname("./../".$dir)).'\Controllers'], function() use ($dir) { |
|
| 37 | + cb()->routeController("plugins/".basename(dirname("./../".$dir)), "\App\CBPlugins\\".basename(dirname("./../".$dir))."\Controllers\\".basename(dirname("./../".$dir))."Controller"); |
|
| 38 | 38 | }); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | $plugins = scandir(app_path("CBPlugins")); |
| 44 | 44 | |
| 45 | 45 | $result = []; |
| 46 | - foreach($plugins as $plugin) { |
|
| 47 | - if($plugin != "." && $plugin != "..") { |
|
| 46 | + foreach ($plugins as $plugin) { |
|
| 47 | + if ($plugin != "." && $plugin != "..") { |
|
| 48 | 48 | $basename = basename($plugin); |
| 49 | 49 | $row = json_decode(file_get_contents(app_path("CBPlugins".DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR."plugin.json")), true); |
| 50 | - if($row) { |
|
| 50 | + if ($row) { |
|
| 51 | 51 | $result[] = [ |
| 52 | 52 | "name"=>$row['name'], |
| 53 | 53 | "version"=>$row['version'], |
@@ -15,8 +15,11 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public static function has($key) |
| 17 | 17 | { |
| 18 | - if(file_exists(app_path("CBPlugins/".$key))) return true; |
|
| 19 | - else return false; |
|
| 18 | + if(file_exists(app_path("CBPlugins/".$key))) { |
|
| 19 | + return true; |
|
| 20 | + } else { |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 20 | 23 | } |
| 21 | 24 | |
| 22 | 25 | public static function isNeedUpgrade($pluginKey, $versionToCompare) |
@@ -24,7 +27,7 @@ discard block |
||
| 24 | 27 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$pluginKey."/plugin.json")), true); |
| 25 | 28 | if($pluginJson) { |
| 26 | 29 | return version_compare($pluginJson['version'], $versionToCompare,"!="); |
| 27 | - }else{ |
|
| 30 | + } else{ |
|
| 28 | 31 | return false; |
| 29 | 32 | } |
| 30 | 33 | } |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | public function getIndex() { |
| 29 | 29 | $data = []; |
| 30 | 30 | $data['result'] = $this->fetchPluginData(); |
| 31 | - return view($this->view.'.index',$data); |
|
| 31 | + return view($this->view.'.index', $data); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function getInstall($key) |
| 35 | 35 | { |
| 36 | 36 | $pluginData = $this->fetchPluginData(); |
| 37 | 37 | |
| 38 | - if(isset($pluginData[$key])) { |
|
| 38 | + if (isset($pluginData[$key])) { |
|
| 39 | 39 | $plugin = $pluginData[$key]; |
| 40 | 40 | |
| 41 | 41 | // Create temp file of zip plugin |
@@ -55,31 +55,31 @@ discard block |
||
| 55 | 55 | // Rename |
| 56 | 56 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
| 57 | 57 | |
| 58 | - return cb()->redirectBack('Install / update plugin has been succesfull!','success'); |
|
| 58 | + return cb()->redirectBack('Install / update plugin has been succesfull!', 'success'); |
|
| 59 | 59 | |
| 60 | 60 | } else { |
| 61 | 61 | return cb()->redirectBack("Failed to install/update, can't open the plugin archive"); |
| 62 | 62 | } |
| 63 | - }else{ |
|
| 63 | + } else { |
|
| 64 | 64 | return cb()->redirectBack('Failed to install/update, plugin key is not found'); |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | private function fetchPluginData() |
| 69 | 69 | { |
| 70 | - if($data = Cache::get("plugin_store_data")) { |
|
| 70 | + if ($data = Cache::get("plugin_store_data")) { |
|
| 71 | 71 | return $data; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9")); |
| 75 | 75 | $result = []; |
| 76 | - if($data) { |
|
| 76 | + if ($data) { |
|
| 77 | 77 | $data = json_decode($data, true); |
| 78 | - if($data['status']==true) { |
|
| 78 | + if ($data['status'] == true) { |
|
| 79 | 79 | |
| 80 | - foreach($data['data'] as $item) { |
|
| 80 | + foreach ($data['data'] as $item) { |
|
| 81 | 81 | $key = $item['key']; |
| 82 | - $result[ $key ] = $item; |
|
| 82 | + $result[$key] = $item; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $result = collect($result)->sortBy("name")->all(); |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | } else { |
| 61 | 61 | return cb()->redirectBack("Failed to install/update, can't open the plugin archive"); |
| 62 | 62 | } |
| 63 | - }else{ |
|
| 63 | + } else{ |
|
| 64 | 64 | return cb()->redirectBack('Failed to install/update, plugin key is not found'); |
| 65 | 65 | } |
| 66 | 66 | } |