| Conditions | 1 |
| Paths | 1 |
| Total Lines | 75 |
| Code Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| 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 namespace Modules\User\Database\Seeders; |
||
| 14 | public function run() |
||
| 15 | { |
||
| 16 | Model::unguard(); |
||
| 17 | |||
| 18 | $groups = Sentinel::getRoleRepository(); |
||
| 19 | |||
| 20 | // Create an Admin group |
||
| 21 | $groups->createModel()->create( |
||
| 22 | [ |
||
| 23 | 'name' => 'Admin', |
||
| 24 | 'slug' => 'admin', |
||
| 25 | ] |
||
| 26 | ); |
||
| 27 | |||
| 28 | // Create an Users group |
||
| 29 | $groups->createModel()->create( |
||
| 30 | [ |
||
| 31 | 'name' => 'User', |
||
| 32 | 'slug' => 'user', |
||
| 33 | ] |
||
| 34 | ); |
||
| 35 | |||
| 36 | // Save the permissions |
||
| 37 | $group = Sentinel::findRoleBySlug('admin'); |
||
| 38 | $group->permissions = [ |
||
| 39 | 'dashboard.index' => true, |
||
| 40 | 'dashboard.update' => true, |
||
| 41 | 'dashboard.reset' => true, |
||
| 42 | /* Workbench */ |
||
| 43 | 'workshop.modules.index' => true, |
||
| 44 | 'workshop.modules.show' => true, |
||
| 45 | 'workshop.modules.disable' => true, |
||
| 46 | 'workshop.modules.enable' => true, |
||
| 47 | 'workshop.themes.index' => true, |
||
| 48 | 'workshop.themes.show' => true, |
||
| 49 | /* Roles */ |
||
| 50 | 'user.roles.index' => true, |
||
| 51 | 'user.roles.create' => true, |
||
| 52 | 'user.roles.edit' => true, |
||
| 53 | 'user.roles.destroy' => true, |
||
| 54 | /* Users */ |
||
| 55 | 'user.users.index' => true, |
||
| 56 | 'user.users.create' => true, |
||
| 57 | 'user.users.edit' => true, |
||
| 58 | 'user.users.destroy' => true, |
||
| 59 | /* Menu */ |
||
| 60 | 'menu.menus.index' => true, |
||
| 61 | 'menu.menus.create' => true, |
||
| 62 | 'menu.menus.edit' => true, |
||
| 63 | 'menu.menus.destroy' => true, |
||
| 64 | 'menu.menuitems.index' => true, |
||
| 65 | 'menu.menuitems.create' => true, |
||
| 66 | 'menu.menuitems.edit' => true, |
||
| 67 | 'menu.menuitems.destroy' => true, |
||
| 68 | /* Media */ |
||
| 69 | 'media.medias.index' => true, |
||
| 70 | 'media.medias.create' => true, |
||
| 71 | 'media.medias.edit' => true, |
||
| 72 | 'media.medias.destroy' => true, |
||
| 73 | /* Settings */ |
||
| 74 | 'setting.settings.index' => true, |
||
| 75 | 'setting.settings.edit' => true, |
||
| 76 | /* Page */ |
||
| 77 | 'page.pages.index' => true, |
||
| 78 | 'page.pages.create' => true, |
||
| 79 | 'page.pages.edit' => true, |
||
| 80 | 'page.pages.destroy' => true, |
||
| 81 | /* Translation */ |
||
| 82 | 'translation.translations.index' => true, |
||
| 83 | 'translation.translations.edit' => true, |
||
| 84 | 'translation.translations.export' => true, |
||
| 85 | 'translation.translations.import' => true, |
||
| 86 | ]; |
||
| 87 | $group->save(); |
||
| 88 | } |
||
| 89 | } |
||
| 90 |