@@ -7,7 +7,7 @@ |
||
| 7 | 7 | name="{{ $column->getName() }}" id="{{ $column->getName() }}"> |
| 8 | 8 | <option value="">** Select a {{ $column->getLabel() }}</option> |
| 9 | 9 | <?php |
| 10 | - $columnValue = old($column->getName())?:($column->getDefaultValue())?:$column->getValue(); |
|
| 10 | + $columnValue = old($column->getName()) ?: ($column->getDefaultValue()) ?: $column->getValue(); |
|
| 11 | 11 | ?> |
| 12 | 12 | @foreach($column->getOptions() as $key=>$value) |
| 13 | 13 | <option {{ $columnValue==$key?'selected':'' }} value="{{ $key }}">{{ $value }}</option> |
@@ -29,16 +29,16 @@ |
||
| 29 | 29 | |
| 30 | 30 | columnSingleton()->setColumn($this->index, $data); |
| 31 | 31 | |
| 32 | - if(is_callable($query)) { |
|
| 32 | + if (is_callable($query)) { |
|
| 33 | 33 | $result = call_user_func($query); |
| 34 | - }else{ |
|
| 34 | + } else { |
|
| 35 | 35 | $result = DB::select(DB::raw($query)); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if($result) { |
|
| 38 | + if ($result) { |
|
| 39 | 39 | $options = []; |
| 40 | - foreach($result as $r) { |
|
| 41 | - $options[ $r->key ] = $r->label; |
|
| 40 | + foreach ($result as $r) { |
|
| 41 | + $options[$r->key] = $r->label; |
|
| 42 | 42 | } |
| 43 | 43 | $this->options($options); |
| 44 | 44 | } |
@@ -18,8 +18,8 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | public function handle($request, Closure $next) |
| 20 | 20 | { |
| 21 | - if(auth()->guest()) { |
|
| 22 | - return cb()->redirect(cb()->getLoginUrl("login"),trans('cb::cb.please_login_for_first'),'warning'); |
|
| 21 | + if (auth()->guest()) { |
|
| 22 | + return cb()->redirect(cb()->getLoginUrl("login"), trans('cb::cb.please_login_for_first'), 'warning'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | (new CBHook())->beforeBackendMiddleware($request); |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | { |
| 22 | 22 | $option = $column->getOptions(); |
| 23 | 23 | $key = $row->{ $column->getField() }; |
| 24 | - return @$option[ $key ]; |
|
| 24 | + return @$option[$key]; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function detailRender($row, $column) |
@@ -37,15 +37,15 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function make() { |
| 40 | - $name = trim(($this->name)?:ucwords(str_replace("_"," ",$this->table))); |
|
| 40 | + $name = trim(($this->name) ?: ucwords(str_replace("_", " ", $this->table))); |
|
| 41 | 41 | |
| 42 | 42 | $template = file_get_contents(__DIR__."/../templates/FooBarController.stub"); |
| 43 | 43 | |
| 44 | 44 | //Replace table |
| 45 | - $template = str_replace("{table}",'"'.$this->table.'"', $template); |
|
| 45 | + $template = str_replace("{table}", '"'.$this->table.'"', $template); |
|
| 46 | 46 | |
| 47 | 47 | //Replace permalink |
| 48 | - $permalink = strtolower(Str::slug($name,"_")); |
|
| 48 | + $permalink = strtolower(Str::slug($name, "_")); |
|
| 49 | 49 | $template = str_replace("{permalink}", '"'.$permalink.'"', $template); |
| 50 | 50 | |
| 51 | 51 | //Replace Page title |
@@ -53,20 +53,20 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | //Replace scaffolding |
| 55 | 55 | $scaffold = ""; |
| 56 | - foreach($this->columns as $field) { |
|
| 56 | + foreach ($this->columns as $field) { |
|
| 57 | 57 | $label = $field['column_label']; |
| 58 | 58 | $column = $field['column_field']; |
| 59 | - $help = isset($field['column_help'])?"->help(\"".$field['column_help']."\")":""; |
|
| 60 | - $required = ($field['column_mandatory']=="on")?"":"->required(false)"; |
|
| 61 | - $indexShow = ($field['column_browse']=="on")?"":"->showIndex(false)"; |
|
| 62 | - $detailShow = ($field['column_detail']=="on")?"":"->showDetail(false)"; |
|
| 63 | - $editShow = ($field['column_edit']=="on")?"":"->showEdit(false)"; |
|
| 64 | - $addShow = ($field['column_add']=="on")?"":"->showAdd(false)"; |
|
| 59 | + $help = isset($field['column_help']) ? "->help(\"".$field['column_help']."\")" : ""; |
|
| 60 | + $required = ($field['column_mandatory'] == "on") ? "" : "->required(false)"; |
|
| 61 | + $indexShow = ($field['column_browse'] == "on") ? "" : "->showIndex(false)"; |
|
| 62 | + $detailShow = ($field['column_detail'] == "on") ? "" : "->showDetail(false)"; |
|
| 63 | + $editShow = ($field['column_edit'] == "on") ? "" : "->showEdit(false)"; |
|
| 64 | + $addShow = ($field['column_add'] == "on") ? "" : "->showAdd(false)"; |
|
| 65 | 65 | $optionTable = $field['column_option_table']; |
| 66 | 66 | $optionValue = $field['column_option_value']; |
| 67 | 67 | $optionDisplay = $field['column_option_display']; |
| 68 | 68 | $optionSqlCondition = $field['column_option_sql_condition']; |
| 69 | - $optionSqlCondition = str_replace('"',"'", $optionSqlCondition); |
|
| 69 | + $optionSqlCondition = str_replace('"', "'", $optionSqlCondition); |
|
| 70 | 70 | $sqlRawQuery = $field['column_sql_query']; |
| 71 | 71 | $options = $field['column_options']; |
| 72 | 72 | $imageResizeWidth = $field['column_image_width']; |
@@ -82,45 +82,45 @@ discard block |
||
| 82 | 82 | $moneyDecimalSeparator = $field['column_money_decimal_separator']; |
| 83 | 83 | |
| 84 | 84 | // Additional Attributes |
| 85 | - $additional = $required . $indexShow . $detailShow . $addShow . $editShow . $help ; |
|
| 85 | + $additional = $required.$indexShow.$detailShow.$addShow.$editShow.$help; |
|
| 86 | 86 | |
| 87 | 87 | // Additional money |
| 88 | - $additional .= ($moneyPrefix && $field['column_type']=='money')?"->prefix('".$moneyPrefix."')":""; |
|
| 89 | - $additional .= ($moneyPrecision && $field['column_type']=='money')?"->precision('".$moneyPrecision."')":""; |
|
| 90 | - $additional .= ($moneyThousandSeparator && $field['column_type']=='money')?"->thousandSeparator('".$moneyThousandSeparator."')":""; |
|
| 91 | - $additional .= ($moneyDecimalSeparator && $field['column_type']=='money')?"->decimalSeparator('".$moneyDecimalSeparator."')":""; |
|
| 88 | + $additional .= ($moneyPrefix && $field['column_type'] == 'money') ? "->prefix('".$moneyPrefix."')" : ""; |
|
| 89 | + $additional .= ($moneyPrecision && $field['column_type'] == 'money') ? "->precision('".$moneyPrecision."')" : ""; |
|
| 90 | + $additional .= ($moneyThousandSeparator && $field['column_type'] == 'money') ? "->thousandSeparator('".$moneyThousandSeparator."')" : ""; |
|
| 91 | + $additional .= ($moneyDecimalSeparator && $field['column_type'] == 'money') ? "->decimalSeparator('".$moneyDecimalSeparator."')" : ""; |
|
| 92 | 92 | |
| 93 | 93 | // Additional for image & file type |
| 94 | - $additional .= ($fileEncrypt && in_array($field['column_type'],['file','image']))?"->encrypt(true)":""; |
|
| 95 | - $additional .= ($imageResizeWidth && in_array($field['column_type'],['file','image']))?"->resize(".$imageResizeWidth.",".$imageResizeHeight.")":""; |
|
| 94 | + $additional .= ($fileEncrypt && in_array($field['column_type'], ['file', 'image'])) ? "->encrypt(true)" : ""; |
|
| 95 | + $additional .= ($imageResizeWidth && in_array($field['column_type'], ['file', 'image'])) ? "->resize(".$imageResizeWidth.",".$imageResizeHeight.")" : ""; |
|
| 96 | 96 | |
| 97 | 97 | // Additional for date & datetime |
| 98 | - $additional .= ($dateFormat && in_array($field['column_type'],['date','datetime']))?"->format('".$dateFormat."')":""; |
|
| 98 | + $additional .= ($dateFormat && in_array($field['column_type'], ['date', 'datetime'])) ? "->format('".$dateFormat."')" : ""; |
|
| 99 | 99 | |
| 100 | 100 | // Additional for text |
| 101 | - $additional .= ($textDisplayLimit!="" && in_array($field['column_type'],['text','text_area','wysiwyg']))?"->strLimit(".$textDisplayLimit.")":""; |
|
| 102 | - $additional .= ($maxCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->maxLength(".$maxCharacter.")":""; |
|
| 103 | - $additional .= ($minCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->minLength(".$minCharacter.")":""; |
|
| 101 | + $additional .= ($textDisplayLimit != "" && in_array($field['column_type'], ['text', 'text_area', 'wysiwyg'])) ? "->strLimit(".$textDisplayLimit.")" : ""; |
|
| 102 | + $additional .= ($maxCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->maxLength(".$maxCharacter.")" : ""; |
|
| 103 | + $additional .= ($minCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->minLength(".$minCharacter.")" : ""; |
|
| 104 | 104 | |
| 105 | 105 | $methodName = Str::studly($field['column_type']); |
| 106 | - if($label && $column) { |
|
| 107 | - if(in_array($field['column_type'],['radio','select_option','checkbox'])) { |
|
| 108 | - if($options) { |
|
| 106 | + if ($label && $column) { |
|
| 107 | + if (in_array($field['column_type'], ['radio', 'select_option', 'checkbox'])) { |
|
| 108 | + if ($options) { |
|
| 109 | 109 | $optResult = []; |
| 110 | - foreach($options as $opt) { |
|
| 110 | + foreach ($options as $opt) { |
|
| 111 | 111 | $optResult[$opt['key']] = $opt['label']; |
| 112 | 112 | } |
| 113 | - $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '")->options('.min_var_export($optResult).')' . $additional . ';' . "\n\t\t"; |
|
| 113 | + $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")->options('.min_var_export($optResult).')'.$additional.';'."\n\t\t"; |
|
| 114 | 114 | } |
| 115 | - }elseif (in_array($field['column_type'],['radio_table','select_table'])) { |
|
| 115 | + }elseif (in_array($field['column_type'], ['radio_table', 'select_table'])) { |
|
| 116 | 116 | if ($optionTable && $optionValue && $optionDisplay) { |
| 117 | - $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '",["table"=>"' . $optionTable . '","value_option"=>"' . $optionValue . '","display_option"=>"' . $optionDisplay . '","sql_condition"=>"' . $optionSqlCondition . '"])' . $additional . ';' . "\n\t\t"; |
|
| 117 | + $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'",["table"=>"'.$optionTable.'","value_option"=>"'.$optionValue.'","display_option"=>"'.$optionDisplay.'","sql_condition"=>"'.$optionSqlCondition.'"])'.$additional.';'."\n\t\t"; |
|
| 118 | 118 | } |
| 119 | 119 | }elseif ($field['column_type'] == "select_query") { |
| 120 | - if($sqlRawQuery && Str::contains($sqlRawQuery,["as `key`","as `label`"])) { |
|
| 121 | - $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '","'.$sqlRawQuery.'")' . $additional . ';' . "\n\t\t"; |
|
| 120 | + if ($sqlRawQuery && Str::contains($sqlRawQuery, ["as `key`", "as `label`"])) { |
|
| 121 | + $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'","'.$sqlRawQuery.'")'.$additional.';'."\n\t\t"; |
|
| 122 | 122 | } |
| 123 | - }else{ |
|
| 123 | + } else { |
|
| 124 | 124 | $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")'.$additional.';'."\n\t\t"; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | $module['controller'] = $filename; |
| 144 | 144 | $module['last_column_build'] = json_encode($this->columns); |
| 145 | 145 | |
| 146 | - if($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name",$this->table)->first()) { |
|
| 147 | - DB::table("cb_modules")->where("id",$moduleData->id)->update($module); |
|
| 146 | + if ($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name", $this->table)->first()) { |
|
| 147 | + DB::table("cb_modules")->where("id", $moduleData->id)->update($module); |
|
| 148 | 148 | $id_modules = $moduleData->id; |
| 149 | - }else{ |
|
| 149 | + } else { |
|
| 150 | 150 | $id_modules = DB::table('cb_modules')->insertGetId($module); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | $menu['name'] = $module['name']; |
| 156 | 156 | $menu['type'] = 'module'; |
| 157 | 157 | $menu['cb_modules_id'] = $id_modules; |
| 158 | - if(isset($moduleData)) { |
|
| 159 | - DB::table("cb_menus")->where("cb_modules_id",$moduleData->id)->update($menu); |
|
| 160 | - }else{ |
|
| 158 | + if (isset($moduleData)) { |
|
| 159 | + DB::table("cb_menus")->where("cb_modules_id", $moduleData->id)->update($menu); |
|
| 160 | + } else { |
|
| 161 | 161 | DB::table('cb_menus')->insertGetId($menu); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -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 | /* |
@@ -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) { |
@@ -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 | } |