| Conditions | 4 |
| Paths | 4 |
| Total Lines | 182 |
| Code Lines | 137 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 46 | public function run() |
||
| 47 | { |
||
| 48 | |||
| 49 | $data = [ |
||
| 50 | |||
| 51 | //LOGIN REGISTER STYLE |
||
| 52 | [ |
||
| 53 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 54 | 'name' => 'login_background_color', |
||
| 55 | 'label' => 'Login Background Color', |
||
| 56 | 'content' => null, |
||
| 57 | 'content_input_type' => 'text', |
||
| 58 | 'group_setting' => trans('crudbooster.login_register_style'), |
||
| 59 | 'dataenum' => null, |
||
| 60 | 'helper' => 'Input hexacode', |
||
| 61 | ], |
||
| 62 | [ |
||
| 63 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 64 | 'name' => 'login_font_color', |
||
| 65 | 'label' => 'Login Font Color', |
||
| 66 | 'content' => null, |
||
| 67 | 'content_input_type' => 'text', |
||
| 68 | 'group_setting' => trans('crudbooster.login_register_style'), |
||
| 69 | 'dataenum' => null, |
||
| 70 | 'helper' => 'Input hexacode', |
||
| 71 | ], |
||
| 72 | [ |
||
| 73 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 74 | 'name' => 'login_background_image', |
||
| 75 | 'label' => 'Login Background Image', |
||
| 76 | 'content' => null, |
||
| 77 | 'content_input_type' => 'upload_image', |
||
| 78 | 'group_setting' => trans('crudbooster.login_register_style'), |
||
| 79 | 'dataenum' => null, |
||
| 80 | 'helper' => null, |
||
| 81 | ], |
||
| 82 | |||
| 83 | //EMAIL SETTING |
||
| 84 | [ |
||
| 85 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 86 | 'name' => 'email_sender', |
||
| 87 | 'label' => 'Email Sender', |
||
| 88 | 'content' => '[email protected]', |
||
| 89 | 'content_input_type' => 'text', |
||
| 90 | 'group_setting' => trans('crudbooster.email_setting'), |
||
| 91 | 'dataenum' => null, |
||
| 92 | 'helper' => null, |
||
| 93 | ], |
||
| 94 | [ |
||
| 95 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 96 | 'name' => 'smtp_driver', |
||
| 97 | 'label' => 'Mail Driver', |
||
| 98 | 'content' => 'mail', |
||
| 99 | 'content_input_type' => 'select', |
||
| 100 | 'group_setting' => trans('crudbooster.email_setting'), |
||
| 101 | 'dataenum' => 'smtp,mail,sendmail', |
||
| 102 | 'helper' => null, |
||
| 103 | ], |
||
| 104 | [ |
||
| 105 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 106 | 'name' => 'smtp_host', |
||
| 107 | 'label' => 'SMTP Host', |
||
| 108 | 'content' => '', |
||
| 109 | 'content_input_type' => 'text', |
||
| 110 | 'group_setting' => trans('crudbooster.email_setting'), |
||
| 111 | 'dataenum' => null, |
||
| 112 | 'helper' => null, |
||
| 113 | ], |
||
| 114 | [ |
||
| 115 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 116 | 'name' => 'smtp_port', |
||
| 117 | 'label' => 'SMTP Port', |
||
| 118 | 'content' => '25', |
||
| 119 | 'content_input_type' => 'text', |
||
| 120 | 'group_setting' => trans('crudbooster.email_setting'), |
||
| 121 | 'dataenum' => null, |
||
| 122 | 'helper' => 'default 25', |
||
| 123 | ], |
||
| 124 | [ |
||
| 125 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 126 | 'name' => 'smtp_username', |
||
| 127 | 'label' => 'SMTP Username', |
||
| 128 | 'content' => '', |
||
| 129 | 'content_input_type' => 'text', |
||
| 130 | 'group_setting' => trans('crudbooster.email_setting'), |
||
| 131 | 'dataenum' => null, |
||
| 132 | 'helper' => null, |
||
| 133 | ], |
||
| 134 | [ |
||
| 135 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 136 | 'name' => 'smtp_password', |
||
| 137 | 'label' => 'SMTP Password', |
||
| 138 | 'content' => '', |
||
| 139 | 'content_input_type' => 'text', |
||
| 140 | 'group_setting' => trans('crudbooster.email_setting'), |
||
| 141 | 'dataenum' => null, |
||
| 142 | 'helper' => null, |
||
| 143 | ], |
||
| 144 | |||
| 145 | //APPLICATION SETTING |
||
| 146 | [ |
||
| 147 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 148 | 'name' => 'appname', |
||
| 149 | 'label' => 'Application Name', |
||
| 150 | 'group_setting' => trans('crudbooster.application_setting'), |
||
| 151 | 'content' => 'CRUDBooster', |
||
| 152 | 'content_input_type' => 'text', |
||
| 153 | 'dataenum' => null, |
||
| 154 | 'helper' => null, |
||
| 155 | ], |
||
| 156 | [ |
||
| 157 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 158 | 'name' => 'default_paper_size', |
||
| 159 | 'label' => 'Default Paper Print Size', |
||
| 160 | 'group_setting' => trans('crudbooster.application_setting'), |
||
| 161 | 'content' => 'Legal', |
||
| 162 | 'content_input_type' => 'text', |
||
| 163 | 'dataenum' => null, |
||
| 164 | 'helper' => 'Paper size, ex : A4, Legal, etc', |
||
| 165 | ], |
||
| 166 | [ |
||
| 167 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 168 | 'name' => 'logo', |
||
| 169 | 'label' => 'Logo', |
||
| 170 | 'content' => '', |
||
| 171 | 'content_input_type' => 'upload_image', |
||
| 172 | 'group_setting' => trans('crudbooster.application_setting'), |
||
| 173 | 'dataenum' => null, |
||
| 174 | 'helper' => null, |
||
| 175 | ], |
||
| 176 | [ |
||
| 177 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 178 | 'name' => 'favicon', |
||
| 179 | 'label' => 'Favicon', |
||
| 180 | 'content' => '', |
||
| 181 | 'content_input_type' => 'upload_image', |
||
| 182 | 'group_setting' => trans('crudbooster.application_setting'), |
||
| 183 | 'dataenum' => null, |
||
| 184 | 'helper' => null, |
||
| 185 | ], |
||
| 186 | [ |
||
| 187 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 188 | 'name' => 'api_debug_mode', |
||
| 189 | 'label' => 'API Debug Mode', |
||
| 190 | 'content' => 'true', |
||
| 191 | 'content_input_type' => 'select', |
||
| 192 | 'group_setting' => trans('crudbooster.application_setting'), |
||
| 193 | 'dataenum' => 'true,false', |
||
| 194 | 'helper' => null, |
||
| 195 | ], |
||
| 196 | [ |
||
| 197 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 198 | 'name' => 'google_api_key', |
||
| 199 | 'label' => 'Google API Key', |
||
| 200 | 'content' => '', |
||
| 201 | 'content_input_type' => 'text', |
||
| 202 | 'group_setting' => trans('crudbooster.application_setting'), |
||
| 203 | 'dataenum' => null, |
||
| 204 | 'helper' => null, |
||
| 205 | ], |
||
| 206 | [ |
||
| 207 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 208 | 'name' => 'google_fcm_key', |
||
| 209 | 'label' => 'Google FCM Key', |
||
| 210 | 'content' => '', |
||
| 211 | 'content_input_type' => 'text', |
||
| 212 | 'group_setting' => trans('crudbooster.application_setting'), |
||
| 213 | 'dataenum' => null, |
||
| 214 | 'helper' => null, |
||
| 215 | ], |
||
| 216 | ]; |
||
| 217 | |||
| 218 | foreach ($data as $row) { |
||
| 219 | $count = DB::table('cms_settings')->where('name', $row['name'])->count(); |
||
| 220 | if ($count) { |
||
| 221 | if ($count > 1) { |
||
| 222 | $newsId = DB::table('cms_settings')->where('name', $row['name'])->orderby('id', 'asc')->take(1)->first(); |
||
| 223 | DB::table('cms_settings')->where('name', $row['name'])->where('id', '!=', $newsId->id)->delete(); |
||
| 224 | } |
||
| 225 | continue; |
||
| 226 | } |
||
| 227 | DB::table('cms_settings')->insert($row); |
||
| 228 | } |
||
| 459 |