| Conditions | 3 |
| Paths | 3 |
| Total Lines | 139 |
| Code Lines | 93 |
| 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 |
||
| 298 | public function run() |
||
| 299 | { |
||
| 300 | |||
| 301 | /* |
||
| 302 | 1 = Public |
||
| 303 | 2 = Setting |
||
| 304 | */ |
||
| 305 | |||
| 306 | $data = [ |
||
| 307 | [ |
||
| 308 | |||
| 309 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 310 | 'name' => trans('crudbooster.Notifications'), |
||
| 311 | 'icon' => 'fa fa-cog', |
||
| 312 | 'path' => 'notifications', |
||
| 313 | 'table_name' => 'cms_notifications', |
||
| 314 | 'controller' => 'NotificationsController', |
||
| 315 | 'is_protected' => 1, |
||
| 316 | 'is_active' => 1, |
||
| 317 | ], |
||
| 318 | [ |
||
| 319 | |||
| 320 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 321 | 'name' => trans('crudbooster.Privileges'), |
||
| 322 | 'icon' => 'fa fa-cog', |
||
| 323 | 'path' => 'privileges', |
||
| 324 | 'table_name' => 'cms_privileges', |
||
| 325 | 'controller' => 'PrivilegesController', |
||
| 326 | 'is_protected' => 1, |
||
| 327 | 'is_active' => 1, |
||
| 328 | ], |
||
| 329 | [ |
||
| 330 | |||
| 331 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 332 | 'name' => trans('crudbooster.Privileges_Roles'), |
||
| 333 | 'icon' => 'fa fa-cog', |
||
| 334 | 'path' => 'privileges_roles', |
||
| 335 | 'table_name' => 'cms_privileges_roles', |
||
| 336 | 'controller' => 'PrivilegesRolesController', |
||
| 337 | 'is_protected' => 1, |
||
| 338 | 'is_active' => 1, |
||
| 339 | ], |
||
| 340 | [ |
||
| 341 | |||
| 342 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 343 | 'name' => trans('crudbooster.Users_Management'), |
||
| 344 | 'icon' => 'fa fa-users', |
||
| 345 | 'path' => 'users', |
||
| 346 | 'table_name' => 'cms_users', |
||
| 347 | 'controller' => 'AdminCmsUsersController', |
||
| 348 | 'is_protected' => 0, |
||
| 349 | 'is_active' => 1, |
||
| 350 | ], |
||
| 351 | [ |
||
| 352 | |||
| 353 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 354 | 'name' => trans('crudbooster.settings'), |
||
| 355 | 'icon' => 'fa fa-cog', |
||
| 356 | 'path' => 'settings', |
||
| 357 | 'table_name' => 'cms_settings', |
||
| 358 | 'controller' => 'SettingsController', |
||
| 359 | 'is_protected' => 1, |
||
| 360 | 'is_active' => 1, |
||
| 361 | ], |
||
| 362 | [ |
||
| 363 | |||
| 364 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 365 | 'name' => trans('crudbooster.Module_Generator'), |
||
| 366 | 'icon' => 'fa fa-database', |
||
| 367 | 'path' => 'module_generator', |
||
| 368 | 'table_name' => 'cms_moduls', |
||
| 369 | 'controller' => 'ModulsController', |
||
| 370 | 'is_protected' => 1, |
||
| 371 | 'is_active' => 1, |
||
| 372 | ], |
||
| 373 | [ |
||
| 374 | |||
| 375 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 376 | 'name' => trans('crudbooster.Menu_Management'), |
||
| 377 | 'icon' => 'fa fa-bars', |
||
| 378 | 'path' => 'menu_management', |
||
| 379 | 'table_name' => 'cms_menus', |
||
| 380 | 'controller' => 'MenusController', |
||
| 381 | 'is_protected' => 1, |
||
| 382 | 'is_active' => 1, |
||
| 383 | ], |
||
| 384 | [ |
||
| 385 | |||
| 386 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 387 | 'name' => trans('crudbooster.Email_Templates'), |
||
| 388 | 'icon' => 'fa fa-envelope-o', |
||
| 389 | 'path' => 'email_templates', |
||
| 390 | 'table_name' => 'cms_email_templates', |
||
| 391 | 'controller' => 'EmailTemplatesController', |
||
| 392 | 'is_protected' => 1, |
||
| 393 | 'is_active' => 1, |
||
| 394 | ], |
||
| 395 | [ |
||
| 396 | |||
| 397 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 398 | 'name' => trans('crudbooster.Statistic_Builder'), |
||
| 399 | 'icon' => 'fa fa-dashboard', |
||
| 400 | 'path' => 'statistic_builder', |
||
| 401 | 'table_name' => 'cms_statistics', |
||
| 402 | 'controller' => 'StatisticBuilderController', |
||
| 403 | 'is_protected' => 1, |
||
| 404 | 'is_active' => 1, |
||
| 405 | ], |
||
| 406 | [ |
||
| 407 | |||
| 408 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 409 | 'name' => trans('crudbooster.API_Generator'), |
||
| 410 | 'icon' => 'fa fa-cloud-download', |
||
| 411 | 'path' => 'api_generator', |
||
| 412 | 'table_name' => '', |
||
| 413 | 'controller' => 'ApiCustomController', |
||
| 414 | 'is_protected' => 1, |
||
| 415 | 'is_active' => 1, |
||
| 416 | ], |
||
| 417 | [ |
||
| 418 | |||
| 419 | 'created_at' => date('Y-m-d H:i:s'), |
||
| 420 | 'name' => trans('crudbooster.Log_User_Access'), |
||
| 421 | 'icon' => 'fa fa-flag-o', |
||
| 422 | 'path' => 'logs', |
||
| 423 | 'table_name' => 'cms_logs', |
||
| 424 | 'controller' => 'LogsController', |
||
| 425 | 'is_protected' => 1, |
||
| 426 | 'is_active' => 1, |
||
| 427 | ], |
||
| 428 | ]; |
||
| 429 | |||
| 430 | foreach ($data as $k => $d) { |
||
| 431 | if (DB::table('cms_moduls')->where('name', $d['name'])->count()) { |
||
| 432 | unset($data[$k]); |
||
| 433 | } |
||
| 434 | } |
||
| 435 | |||
| 436 | DB::table('cms_moduls')->insert($data); |
||
| 437 | } |
||
| 459 |