| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 14 | public function up() |
||
| 15 | { |
||
| 16 | Schema::create('admin_panel_navigation', function (Blueprint $table) { |
||
| 17 | // These columns are needed for Baum's Nested Set implementation to work. |
||
| 18 | // Column names may be changed, but they *must* all exist and be modified |
||
| 19 | // in the model. |
||
| 20 | // Take a look at the model scaffold comments for details. |
||
| 21 | // We add indexes on parent_id, lft, rgt columns by default. |
||
| 22 | $table->increments('id'); |
||
| 23 | $table->integer('parent_id')->nullable()->index(); |
||
| 24 | $table->integer('lft')->nullable()->index(); |
||
| 25 | $table->integer('rgt')->nullable()->index(); |
||
| 26 | $table->integer('depth')->nullable(); |
||
| 27 | |||
| 28 | // Add needed columns here (f.ex: name, slug, path, etc.) |
||
| 29 | $table->string('name'); |
||
| 30 | $table->string('slug'); |
||
| 31 | $table->string('icon'); |
||
| 32 | $table->boolean('is_active'); |
||
| 33 | |||
| 34 | $table->timestamps(); |
||
| 35 | }); |
||
| 36 | |||
| 37 | $root = new \Yaro\Jarboe\Models\Navigation(); |
||
| 38 | $root->name = 'Root'; |
||
| 39 | $root->slug = ''; |
||
| 40 | $root->is_active = true; |
||
| 41 | $root->icon = ''; |
||
| 42 | $root->save(); |
||
| 43 | |||
| 44 | $panelNode = \Yaro\Jarboe\Models\Navigation::create([ |
||
| 45 | 'name' => 'Admin Panel', |
||
| 46 | 'slug' => 'admin-panel', |
||
| 47 | 'icon' => 'fa-cogs', |
||
| 48 | 'is_active' => true, |
||
| 49 | ])->makeChildOf($root); |
||
| 50 | |||
| 51 | \Yaro\Jarboe\Models\Navigation::create([ |
||
| 52 | 'name' => 'Admins', |
||
| 53 | 'slug' => 'admin-panel/admins', |
||
| 54 | 'icon' => '', |
||
| 55 | 'is_active' => true, |
||
| 56 | ])->makeChildOf($panelNode); |
||
| 57 | \Yaro\Jarboe\Models\Navigation::create([ |
||
| 58 | 'name' => 'Roles & Permissions', |
||
| 59 | 'slug' => 'admin-panel/roles-and-permissions', |
||
| 60 | 'icon' => '', |
||
| 61 | 'is_active' => true, |
||
| 62 | ])->makeChildOf($panelNode); |
||
| 63 | \Yaro\Jarboe\Models\Navigation::create([ |
||
| 64 | 'name' => 'Navigation', |
||
| 65 | 'slug' => 'admin-panel/navigation', |
||
| 66 | 'icon' => '', |
||
| 67 | 'is_active' => true, |
||
| 68 | ])->makeChildOf($panelNode); |
||
| 69 | } |
||
| 70 | |||
| 82 |