Passed
Pull Request — master (#1574)
by
unknown
06:56 queued 02:51
created
src/types/select_table/filter.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
     /** @var \crocodicstudio\crudbooster\types\text\TextModel $column */
3
-    $filterName = "filter_".slug($column->getFilterColumn(),"_");
3
+    $filterName = "filter_".slug($column->getFilterColumn(), "_");
4 4
     $filterValue = sanitizeXSS(request($filterName));
5 5
 ?>
6 6
 <select name="filter_{{ slug($column->getFilterColumn(),"_") }}" style="width: 100%" id="filter_{{ $column->getName()  }}" class="form-control select2">
Please login to merge, or discard this patch.
src/helpers/ModuleGenerator.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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'];
@@ -80,49 +80,49 @@  discard block
 block discarded – undo
80 80
             $moneyPrecision = $field['column_money_precision'];
81 81
             $moneyThousandSeparator = $field['column_money_thousand_separator'];
82 82
             $moneyDecimalSeparator = $field['column_money_decimal_separator'];
83
-            $filterable = ($field['column_filterable']=="on")?"->filterable(true)":"";
84
-            $foreign_key = (isset($field['column_foreign']))?"->foreignKey('".$field['column_foreign']."')":"";
83
+            $filterable = ($field['column_filterable'] == "on") ? "->filterable(true)" : "";
84
+            $foreign_key = (isset($field['column_foreign'])) ? "->foreignKey('".$field['column_foreign']."')" : "";
85 85
 
86 86
             // Additional Attributes
87
-            $additional = $required . $indexShow . $detailShow . $addShow . $editShow . $help . $filterable . $foreign_key ;
87
+            $additional = $required.$indexShow.$detailShow.$addShow.$editShow.$help.$filterable.$foreign_key;
88 88
 
89 89
             // Additional money
90
-            $additional .= ($moneyPrefix && $field['column_type']=='money')?"->prefix('".$moneyPrefix."')":"";
91
-            $additional .= ($moneyPrecision && $field['column_type']=='money')?"->precision('".$moneyPrecision."')":"";
92
-            $additional .= ($moneyThousandSeparator && $field['column_type']=='money')?"->thousandSeparator('".$moneyThousandSeparator."')":"";
93
-            $additional .= ($moneyDecimalSeparator && $field['column_type']=='money')?"->decimalSeparator('".$moneyDecimalSeparator."')":"";
90
+            $additional .= ($moneyPrefix && $field['column_type'] == 'money') ? "->prefix('".$moneyPrefix."')" : "";
91
+            $additional .= ($moneyPrecision && $field['column_type'] == 'money') ? "->precision('".$moneyPrecision."')" : "";
92
+            $additional .= ($moneyThousandSeparator && $field['column_type'] == 'money') ? "->thousandSeparator('".$moneyThousandSeparator."')" : "";
93
+            $additional .= ($moneyDecimalSeparator && $field['column_type'] == 'money') ? "->decimalSeparator('".$moneyDecimalSeparator."')" : "";
94 94
 
95 95
             // Additional for image & file type
96
-            $additional .= ($fileEncrypt && in_array($field['column_type'],['file','image']))?"->encrypt(true)":"";
97
-            $additional .= ($imageResizeWidth && in_array($field['column_type'],['file','image']))?"->resize(".$imageResizeWidth.",".$imageResizeHeight.")":"";
96
+            $additional .= ($fileEncrypt && in_array($field['column_type'], ['file', 'image'])) ? "->encrypt(true)" : "";
97
+            $additional .= ($imageResizeWidth && in_array($field['column_type'], ['file', 'image'])) ? "->resize(".$imageResizeWidth.",".$imageResizeHeight.")" : "";
98 98
 
99 99
             // Additional for date & datetime
100
-            $additional .= ($dateFormat && in_array($field['column_type'],['date','datetime']))?"->format('".$dateFormat."')":"";
100
+            $additional .= ($dateFormat && in_array($field['column_type'], ['date', 'datetime'])) ? "->format('".$dateFormat."')" : "";
101 101
 
102 102
             // Additional for text
103
-            $additional .= ($textDisplayLimit!="" && in_array($field['column_type'],['text','text_area','wysiwyg']))?"->strLimit(".$textDisplayLimit.")":"";
104
-            $additional .= ($maxCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->maxLength(".$maxCharacter.")":"";
105
-            $additional .= ($minCharacter!="" && in_array($field['column_type'],['text','text_area']))?"->minLength(".$minCharacter.")":"";
103
+            $additional .= ($textDisplayLimit != "" && in_array($field['column_type'], ['text', 'text_area', 'wysiwyg'])) ? "->strLimit(".$textDisplayLimit.")" : "";
104
+            $additional .= ($maxCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->maxLength(".$maxCharacter.")" : "";
105
+            $additional .= ($minCharacter != "" && in_array($field['column_type'], ['text', 'text_area'])) ? "->minLength(".$minCharacter.")" : "";
106 106
 
107 107
             $methodName = Str::studly($field['column_type']);
108
-            if($label && $column) {
109
-                if(in_array($field['column_type'],['radio','select_option','checkbox'])) {
110
-                    if($options) {
108
+            if ($label && $column) {
109
+                if (in_array($field['column_type'], ['radio', 'select_option', 'checkbox'])) {
110
+                    if ($options) {
111 111
                         $optResult = [];
112
-                        foreach($options as $opt) {
112
+                        foreach ($options as $opt) {
113 113
                             $optResult[$opt['key']] = $opt['label'];
114 114
                         }
115
-                        $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '")->options('.min_var_export($optResult).')' . $additional . ';' . "\n\t\t";
115
+                        $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")->options('.min_var_export($optResult).')'.$additional.';'."\n\t\t";
116 116
                     }
117
-                }elseif (in_array($field['column_type'],['radio_table','select_table'])) {
117
+                }elseif (in_array($field['column_type'], ['radio_table', 'select_table'])) {
118 118
                     if ($optionTable && $optionValue && $optionDisplay) {
119
-                        $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '",["table"=>"' . $optionTable . '","value_option"=>"' . $optionValue . '","display_option"=>"' . $optionDisplay . '","sql_condition"=>"' . $optionSqlCondition . '"])' . $additional . ';' . "\n\t\t";
119
+                        $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'",["table"=>"'.$optionTable.'","value_option"=>"'.$optionValue.'","display_option"=>"'.$optionDisplay.'","sql_condition"=>"'.$optionSqlCondition.'"])'.$additional.';'."\n\t\t";
120 120
                     }
121 121
                 }elseif ($field['column_type'] == "select_query") {
122
-                    if($sqlRawQuery && Str::contains($sqlRawQuery,["as `key`","as `label`"])) {
123
-                        $scaffold .= '$this->add' . $methodName . '("' . $label . '","' . $column . '","'.$sqlRawQuery.'")' . $additional . ';' . "\n\t\t";
122
+                    if ($sqlRawQuery && Str::contains($sqlRawQuery, ["as `key`", "as `label`"])) {
123
+                        $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'","'.$sqlRawQuery.'")'.$additional.';'."\n\t\t";
124 124
                     }
125
-                }else{
125
+                } else {
126 126
                     $scaffold .= '$this->add'.$methodName.'("'.$label.'","'.$column.'")'.$additional.';'."\n\t\t";
127 127
                 }
128 128
             }
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
         $module['controller'] = $filename;
146 146
         $module['last_column_build'] = json_encode($this->columns);
147 147
 
148
-        if($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name",$this->table)->first()) {
149
-            DB::table("cb_modules")->where("id",$moduleData->id)->update($module);
148
+        if ($moduleData = DB::table("cb_modules")->where("name", $name)->where("table_name", $this->table)->first()) {
149
+            DB::table("cb_modules")->where("id", $moduleData->id)->update($module);
150 150
             $id_modules = $moduleData->id;
151
-        }else{
151
+        } else {
152 152
             $id_modules = DB::table('cb_modules')->insertGetId($module);
153 153
         }
154 154
 
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
         $menu['name'] = $module['name'];
158 158
         $menu['type'] = 'module';
159 159
         $menu['cb_modules_id'] = $id_modules;
160
-        if(isset($moduleData)) {
161
-            DB::table("cb_menus")->where("cb_modules_id",$moduleData->id)->update($menu);
162
-        }else{
160
+        if (isset($moduleData)) {
161
+            DB::table("cb_menus")->where("cb_modules_id", $moduleData->id)->update($menu);
162
+        } else {
163 163
             DB::table('cb_menus')->insertGetId($menu);
164 164
         }
165 165
 
Please login to merge, or discard this patch.
src/views/dev_layouts/modules/appearance/index.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
                                 <label>Dashboard Controller</label>
58 58
                                 <select name="dashboard_controller" class="form-control">
59 59
                                     <option value="">** Default CB</option>
60
-                                    <?php $controllers = glob(app_path("Http/Controllers/*Controller.php"));?>
60
+                                    <?php $controllers = glob(app_path("Http/Controllers/*Controller.php")); ?>
61 61
                                     @foreach($controllers as $controller)
62 62
                                         @if(basename($controller) != "Controller.php")
63 63
                                         <option {{ getSetting("dashboard_controller")==rtrim(basename($controller),".php")?"selected":"" }} value="{{ rtrim(basename($controller),".php") }}">{{ rtrim(basename($controller),".php") }}</option>
Please login to merge, or discard this patch.
src/types/image/Hook.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     {
24 24
         // Direct return value because its been uploaded on client side
25 25
         $ext = strtolower(pathinfo($value, PATHINFO_EXTENSION));
26
-        if(in_array($ext, cbConfig("UPLOAD_IMAGE_EXTENSION_ALLOWED"))) {
26
+        if (in_array($ext, cbConfig("UPLOAD_IMAGE_EXTENSION_ALLOWED"))) {
27 27
             return $value;
28 28
         }
29 29
     }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function detailRender($row, $column)
32 32
     {
33 33
         $column->setValue($row->{ $column->getField() });
34
-        return view("types::image.detail",[
34
+        return view("types::image.detail", [
35 35
             'row'=>$row,
36 36
             'column'=>$column
37 37
         ]);
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function indexRender($row, $column)
41 41
     {
42 42
         $column->setValue($row->{ $column->getField() });
43
-        return view("types::image.index",[
43
+        return view("types::image.index", [
44 44
             'row'=>$row,
45 45
             'column'=>$column
46 46
         ]);
Please login to merge, or discard this patch.
src/types/file/Hook.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function assignment($value, $column)
23 23
     {
24 24
         $ext = strtolower(pathinfo($value, PATHINFO_EXTENSION));
25
-        if(in_array($ext, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
25
+        if (in_array($ext, cbConfig("UPLOAD_FILE_EXTENSION_ALLOWED"))) {
26 26
             return $value;
27 27
         }
28 28
     }
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     public function detailRender($row, $column)
31 31
     {
32 32
         $column->setValue($row->{ $column->getField() });
33
-        return view("types::file.detail",[
33
+        return view("types::file.detail", [
34 34
             'row'=>$row,
35 35
             'column'=>$column
36 36
         ]);
Please login to merge, or discard this patch.
src/controllers/CBController.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 
33 33
     public function getIndex()
34 34
     {
35
-        if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
35
+        if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
36 36
 
37 37
         $query = $this->repository();
38
-        $result = $query->paginate( request("limit")?:$this->data['limit'] );
38
+        $result = $query->paginate(request("limit") ?: $this->data['limit']);
39 39
         $data['result'] = $result;
40 40
 
41 41
         return view("crudbooster::module.index.index", array_merge($data, $this->data));
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 
44 44
     public function getAdd()
45 45
     {
46
-        if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
46
+        if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
47 47
 
48 48
         $data = [];
49 49
         $data['page_title'] = $this->data['page_title'].' : '.cbLang('add');
50 50
         $data['action_url'] = module()->addSaveURL();
51
-        return view('crudbooster::module.form.form',array_merge($data, $this->data));
51
+        return view('crudbooster::module.form.form', array_merge($data, $this->data));
52 52
     }
53 53
 
54 54
     public function postAddSave()
55 55
     {
56
-        if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
56
+        if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
57 57
 
58 58
         try {
59 59
             $this->validation();
@@ -61,38 +61,38 @@  discard block
 block discarded – undo
61 61
             $data = columnSingleton()->getAssignmentData();
62 62
 
63 63
             //Clear data from Primary Key
64
-            unset($data[ cb()->pk($this->data['table']) ]);
64
+            unset($data[cb()->pk($this->data['table'])]);
65 65
 
66
-            if(Schema::hasColumn($this->data['table'], 'created_at')) {
66
+            if (Schema::hasColumn($this->data['table'], 'created_at')) {
67 67
                 $data['created_at'] = date('Y-m-d H:i:s');
68 68
             }
69 69
 
70
-            if(Schema::hasColumn($this->data['table'], 'updated_at')) {
70
+            if (Schema::hasColumn($this->data['table'], 'updated_at')) {
71 71
                 $data['updated_at'] = date('Y-m-d H:i:s');
72 72
             }
73 73
 
74
-            if(isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) {
74
+            if (isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) {
75 75
                 $data = call_user_func($this->data['hook_before_insert'], $data);
76 76
             }
77 77
 
78 78
             $id = DB::table($this->data['table'])->insertGetId($data);
79 79
 
80
-            if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) {
80
+            if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) {
81 81
                 call_user_func($this->data['hook_after_insert'], $id);
82 82
             }
83 83
 
84 84
         } catch (CBValidationException $e) {
85 85
             Log::debug($e);
86
-            return cb()->redirectBack($e->getMessage(),'info');
86
+            return cb()->redirectBack($e->getMessage(), 'info');
87 87
         } catch (\Exception $e) {
88 88
             Log::error($e);
89
-            return cb()->redirectBack(cbLang("something_went_wrong"),'warning');
89
+            return cb()->redirectBack(cbLang("something_went_wrong"), 'warning');
90 90
         }
91 91
 
92
-        if (Str::contains(request("submit"),cbLang("more"))) {
92
+        if (Str::contains(request("submit"), cbLang("more"))) {
93 93
             return cb()->redirectBack(cbLang("the_data_has_been_added"), 'success');
94 94
         } else {
95
-            if(verifyReferalUrl()) {
95
+            if (verifyReferalUrl()) {
96 96
                 return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_added"), 'success');
97 97
             } else {
98 98
                 return cb()->redirect(module()->url(), cbLang("the_data_has_been_added"), 'success');
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
     public function getEdit($id)
104 104
     {
105
-        if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
105
+        if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
106 106
 
107 107
         $data = [];
108 108
         $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first();
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
     public function postEditSave($id)
115 115
     {
116
-        if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
116
+        if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
117 117
 
118 118
         try {
119 119
             $this->validation();
@@ -121,40 +121,40 @@  discard block
 block discarded – undo
121 121
             $data = columnSingleton()->getAssignmentData();
122 122
 
123 123
             // Make sure the Primary Key is not included
124
-            unset($data[ cb()->pk($this->data['table']) ]);
124
+            unset($data[cb()->pk($this->data['table'])]);
125 125
 
126
-            if(Schema::hasColumn($this->data['table'], 'updated_at')) {
126
+            if (Schema::hasColumn($this->data['table'], 'updated_at')) {
127 127
                 $data['updated_at'] = date('Y-m-d H:i:s');
128 128
             }
129 129
 
130 130
             unset($data['created_at']);
131 131
 
132
-            if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) {
132
+            if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) {
133 133
                 $data = call_user_func($this->data['hook_before_update'], $data, $id);
134 134
             }
135 135
 
136 136
             cb()->update($this->data['table'], $id, $data);
137 137
 
138
-            if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) {
138
+            if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) {
139 139
                 call_user_func($this->data['hook_after_update'], $id);
140 140
             }
141 141
 
142 142
         } catch (CBValidationException $e) {
143 143
             Log::debug($e);
144
-            return cb()->redirectBack($e->getMessage(),'info');
144
+            return cb()->redirectBack($e->getMessage(), 'info');
145 145
         } catch (\Exception $e) {
146 146
             Log::error($e);
147
-            return cb()->redirectBack(cbLang("something_went_wrong"),'warning');
147
+            return cb()->redirectBack(cbLang("something_went_wrong"), 'warning');
148 148
         }
149 149
 
150 150
 
151 151
         if (Str::contains(request("submit"), cbLang("more"))) {
152
-            return cb()->redirectBack( cbLang("the_data_has_been_updated"), 'success');
152
+            return cb()->redirectBack(cbLang("the_data_has_been_updated"), 'success');
153 153
         } else {
154
-            if(verifyReferalUrl()) {
155
-                return cb()->redirect(getReferalUrl("url"),  cbLang("the_data_has_been_updated"), 'success');
154
+            if (verifyReferalUrl()) {
155
+                return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_updated"), 'success');
156 156
             } else {
157
-                return cb()->redirect(module()->url(),  cbLang("the_data_has_been_updated"), 'success');
157
+                return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success');
158 158
             }
159 159
 
160 160
         }
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 
163 163
     public function getDelete($id)
164 164
     {
165
-        if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
165
+        if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
166 166
 
167
-        if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) {
167
+        if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) {
168 168
             call_user_func($this->data['hook_before_delete'], $id);
169 169
         }
170 170
 
171
-        $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true;
171
+        $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true;
172 172
 
173
-        if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) {
173
+        if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) {
174 174
             DB::table($this->data['table'])
175 175
                 ->where(getPrimaryKey($this->data['table']), $id)
176 176
                 ->update(['deleted_at' => date('Y-m-d H:i:s')]);
@@ -180,16 +180,16 @@  discard block
 block discarded – undo
180 180
                 ->delete();
181 181
         }
182 182
 
183
-        if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) {
183
+        if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) {
184 184
             call_user_func($this->data['hook_after_delete'], $id);
185 185
         }
186 186
 
187
-        return cb()->redirectBack( cbLang("the_data_has_been_deleted"), 'success');
187
+        return cb()->redirectBack(cbLang("the_data_has_been_deleted"), 'success');
188 188
     }
189 189
 
190 190
     public function getDetail($id)
191 191
     {
192
-        if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
192
+        if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area"));
193 193
 
194 194
         $data = [];
195 195
         $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first();
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function __call($method, $parameters)
210 210
     {
211
-        if($method == "getData") {
211
+        if ($method == "getData") {
212 212
             $key = $parameters[0];
213
-            if(isset($this->data[$key])) {
213
+            if (isset($this->data[$key])) {
214 214
                 return $this->data[$key];
215
-            }else{
215
+            } else {
216 216
                 return null;
217 217
             }
218
-        }else{
218
+        } else {
219 219
             return null;
220 220
         }
221 221
     }
Please login to merge, or discard this patch.
src/controllers/traits/ControllerSetting.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
         $this->setButtonDetail(true);
34 34
         $this->setButtonSave(true);
35 35
         $this->setButtonLimitPage(true);
36
-        $this->hideButtonDeleteWhen(function ($row) { return false; });
37
-        $this->hideButtonDetailWhen(function ($row) { return false; });
38
-        $this->hideButtonEditWhen(function ($row) { return false; });
39
-        $this->style(function () { return null; });
40
-        $this->javascript(function () { return null; });
36
+        $this->hideButtonDeleteWhen(function($row) { return false; });
37
+        $this->hideButtonDetailWhen(function($row) { return false; });
38
+        $this->hideButtonEditWhen(function($row) { return false; });
39
+        $this->style(function() { return null; });
40
+        $this->javascript(function() { return null; });
41 41
     }
42 42
 
43 43
     public function appendAddForm(callable $html) {
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
      * @param ButtonColor $color
158 158
      * @param string $attributes
159 159
      */
160
-    public function addIndexActionButton($label, $actionURL, $fontAwesome_icon=null, $color=null, $attributes = null)
160
+    public function addIndexActionButton($label, $actionURL, $fontAwesome_icon = null, $color = null, $attributes = null)
161 161
     {
162
-        $color = ($color)?:ButtonColor::DARK_BLUE;
162
+        $color = ($color) ?: ButtonColor::DARK_BLUE;
163 163
 
164 164
         $model = new IndexActionButtonModel();
165 165
         $model->setLabel($label);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     public function addSubModule($label, $controllerName, $foreignKey, callable $additionalInfo = null, callable $condition = null, $font = null, $color = null) {
219 219
         $parentPath = $this->getData("permalink");
220 220
         $parentTitle = $this->getData("page_title");
221
-        $this->addActionButton($label,function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) {
221
+        $this->addActionButton($label, function($row) use ($label, $controllerName, $foreignKey, $additionalInfo, $parentPath, $parentTitle) {
222 222
            $actionParameters = [
223 223
                "label"=>$label,
224 224
                "foreignKey"=>$foreignKey,
@@ -227,22 +227,22 @@  discard block
 block discarded – undo
227 227
                "parentTitle"=>$parentTitle
228 228
            ];
229 229
 
230
-            if(isset($additionalInfo) && is_callable($additionalInfo)) {
230
+            if (isset($additionalInfo) && is_callable($additionalInfo)) {
231 231
                 $additionalInfo = call_user_func($additionalInfo, $row);
232
-                if(is_array($additionalInfo)) {
232
+                if (is_array($additionalInfo)) {
233 233
                     $actionParameters['info'] = $additionalInfo;
234 234
                 }
235 235
             }
236 236
 
237 237
            $actionHash = md5(serialize($actionParameters));
238 238
            $actionHashToken = Cache::get("subModule".$actionHash);
239
-           if(!$actionHashToken) {
239
+           if (!$actionHashToken) {
240 240
                $actionHashToken = Str::random(5);
241 241
                Cache::forever("subModule".$actionHash, $actionHashToken);
242 242
                Cache::forever("subModule".$actionHashToken, $actionParameters);
243 243
            }
244 244
 
245
-           return action(class_basename($controllerName)."@getSubModule",['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle);
245
+           return action(class_basename($controllerName)."@getSubModule", ['subModuleKey'=>$actionHashToken])."?ref=".makeReferalUrl($parentTitle);
246 246
         }, $condition, $font, $color);
247 247
 
248 248
     }
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
      * @param $fontAwesome_icon
256 256
      * @param ButtonColor|string $color
257 257
      */
258
-    public function addActionButton($label, $url_target, $condition_callback=null, $fontAwesome_icon=null, $color=null, $confirmation = false)
258
+    public function addActionButton($label, $url_target, $condition_callback = null, $fontAwesome_icon = null, $color = null, $confirmation = false)
259 259
     {
260 260
         $new = new AddActionButtonModel();
261 261
         $new->setLabel($label);
262
-        $new->setIcon($fontAwesome_icon?:"fa fa-bars");
263
-        $new->setColor($color?:"primary");
262
+        $new->setIcon($fontAwesome_icon ?: "fa fa-bars");
263
+        $new->setColor($color ?: "primary");
264 264
         $new->setUrl($url_target);
265 265
         $new->setCondition($condition_callback);
266 266
         $new->setConfirmation($confirmation);
Please login to merge, or discard this patch.
src/routes.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,61 +1,61 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Developer Backend Middleware
4
-Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
4
+Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class],
5 5
     'prefix'=>"developer/".getSetting('developer_path'),
6
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
6
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
7 7
     cb()->routeController("modules", "\crocodicstudio\crudbooster\controllers\DeveloperModulesController");
8 8
     cb()->routeController("menus", "\crocodicstudio\crudbooster\controllers\DeveloperMenusController");
9
-    cb()->routeController("roles","\crocodicstudio\crudbooster\controllers\DeveloperRolesController");
10
-    cb()->routeController("users","\crocodicstudio\crudbooster\controllers\DeveloperUsersController");
11
-    cb()->routeController("plugins","\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController");
12
-    cb()->routeController("mail","\crocodicstudio\crudbooster\controllers\DeveloperMailController");
13
-    cb()->routeController("security","\crocodicstudio\crudbooster\controllers\DeveloperSecurityController");
14
-    cb()->routeController("themes","\crocodicstudio\crudbooster\controllers\DeveloperThemesController");
15
-    cb()->routeController("appearance","\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController");
16
-    cb()->routeController("miscellaneous","\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController");
17
-    cb()->routePost("skip-tutorial","DeveloperDashboardController@postSkipTutorial");
18
-    cb()->routeGet("/","DeveloperDashboardController@getIndex");
9
+    cb()->routeController("roles", "\crocodicstudio\crudbooster\controllers\DeveloperRolesController");
10
+    cb()->routeController("users", "\crocodicstudio\crudbooster\controllers\DeveloperUsersController");
11
+    cb()->routeController("plugins", "\crocodicstudio\crudbooster\controllers\DeveloperPluginStoreController");
12
+    cb()->routeController("mail", "\crocodicstudio\crudbooster\controllers\DeveloperMailController");
13
+    cb()->routeController("security", "\crocodicstudio\crudbooster\controllers\DeveloperSecurityController");
14
+    cb()->routeController("themes", "\crocodicstudio\crudbooster\controllers\DeveloperThemesController");
15
+    cb()->routeController("appearance", "\crocodicstudio\crudbooster\controllers\DeveloperAppearanceController");
16
+    cb()->routeController("miscellaneous", "\crocodicstudio\crudbooster\controllers\DeveloperMiscellaneousController");
17
+    cb()->routePost("skip-tutorial", "DeveloperDashboardController@postSkipTutorial");
18
+    cb()->routeGet("/", "DeveloperDashboardController@getIndex");
19 19
 });
20 20
 
21 21
 // Developer Auth Middleware
22 22
 Route::group(['middleware' => ['web'],
23 23
     'prefix'=>"developer/".getSetting('developer_path'),
24
-    'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
25
-    cb()->routePost("login","AdminAuthController@postLoginDeveloper");
26
-    cb()->routeGet("login","AdminAuthController@getLoginDeveloper");
27
-    cb()->routeGet("logout","AdminAuthController@getLogoutDeveloper");
24
+    'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
25
+    cb()->routePost("login", "AdminAuthController@postLoginDeveloper");
26
+    cb()->routeGet("login", "AdminAuthController@getLoginDeveloper");
27
+    cb()->routeGet("logout", "AdminAuthController@getLogoutDeveloper");
28 28
 });
29 29
 
30 30
 // Routing without any middleware
31
-Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function () {
32
-    if(getSetting("AUTO_REDIRECT_TO_LOGIN")) {
33
-        cb()->routeGet("/","AdminAuthController@getRedirectToLogin");
31
+Route::group(['middleware' => ['web'], 'namespace' => '\crocodicstudio\crudbooster\controllers'], function() {
32
+    if (getSetting("AUTO_REDIRECT_TO_LOGIN")) {
33
+        cb()->routeGet("/", "AdminAuthController@getRedirectToLogin");
34 34
     }
35 35
 });
36 36
 
37 37
 // Routing without any middleware with admin prefix
38
-Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function () {
38
+Route::group(['middleware' => ['web'], 'prefix' => cb()->getAdminPath(), 'namespace' => 'crocodicstudio\crudbooster\controllers'], function() {
39 39
     cb()->routeGet('logout', "AdminAuthController@getLogout");
40 40
 
41
-    if(!getSetting("DISABLE_LOGIN")) {
41
+    if (!getSetting("DISABLE_LOGIN")) {
42 42
         cb()->routePost('login', "AdminAuthController@postLogin");
43 43
         cb()->routeGet('login', "AdminAuthController@getLogin");
44
-        cb()->routeGet("login-verification","AdminAuthController@getLoginVerification");
45
-        cb()->routePost("submit-login-verification","AdminAuthController@postSubmitLoginVerification");
44
+        cb()->routeGet("login-verification", "AdminAuthController@getLoginVerification");
45
+        cb()->routePost("submit-login-verification", "AdminAuthController@postSubmitLoginVerification");
46 46
     }
47 47
 
48
-    if(getSetting("enable_forget")) {
49
-        cb()->routePost("forget","AdminAuthController@postForget");
48
+    if (getSetting("enable_forget")) {
49
+        cb()->routePost("forget", "AdminAuthController@postForget");
50 50
     }
51 51
 
52
-    if(getSetting("enable_register")) {
53
-        cb()->routePost("register","AdminAuthController@postRegister");
52
+    if (getSetting("enable_register")) {
53
+        cb()->routePost("register", "AdminAuthController@postRegister");
54 54
     }
55 55
 });
56 56
 
57 57
 // Routing package controllers
58
-cb()->routeGroupBackend(function () {
58
+cb()->routeGroupBackend(function() {
59 59
     cb()->routeController('profile', '\crocodicstudio\crudbooster\controllers\AdminProfileController');
60 60
 });
61 61
 
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
     'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class],
65 65
     'prefix' => cb()->getAdminPath(),
66 66
     'namespace' => 'App\Http\Controllers',
67
-], function () {
67
+], function() {
68 68
 
69 69
     if (Request::is(cb()->getAdminPath())) {
70
-        if($dashboard = getSetting("dashboard_controller")) {
70
+        if ($dashboard = getSetting("dashboard_controller")) {
71 71
             cb()->routeGet("/", $dashboard."@getIndex");
72
-        }else{
72
+        } else {
73 73
             cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex");
74 74
         }
75 75
     }
76 76
 
77 77
     $controllers = glob(app_path('Http/Controllers/Admin*Controller.php'));
78 78
 
79
-    foreach($controllers as $controller) {
79
+    foreach ($controllers as $controller) {
80 80
         $controllerName = basename($controller);
81
-        $controllerName = rtrim($controllerName,".php");
81
+        $controllerName = rtrim($controllerName, ".php");
82 82
         $className = '\App\Http\Controllers\\'.$controllerName;
83 83
         $controllerClass = new $className();
84
-        if(method_exists($controllerClass, 'cbInit')) {
84
+        if (method_exists($controllerClass, 'cbInit')) {
85 85
             cb()->routeController($controllerClass->getData('permalink'), $controllerName);
86 86
         }
87 87
     }
Please login to merge, or discard this patch.
src/database/migrations/2016_08_07_152421_modify_users.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
      */
13 13
     public function up()
14 14
     {
15
-        Schema::table('users', function (Blueprint $table) {
15
+        Schema::table('users', function(Blueprint $table) {
16 16
             $table->string('photo')->nullable();
17 17
             $table->integer('cb_roles_id');
18 18
             $table->ipAddress("ip_address")->nullable();
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function down()
30 30
     {
31
-        Schema::table('users', function (Blueprint $table) {
32
-            $table->dropColumn(["photo","cb_roles_id","ip_address","user_agent","login_at"]);
31
+        Schema::table('users', function(Blueprint $table) {
32
+            $table->dropColumn(["photo", "cb_roles_id", "ip_address", "user_agent", "login_at"]);
33 33
         });
34 34
     }
35 35
 }
Please login to merge, or discard this patch.