| Conditions | 1 |
| Paths | 1 |
| Total Lines | 68 |
| 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 |
||
| 13 | public function up() |
||
| 14 | { |
||
| 15 | Schema::create( |
||
| 16 | 'taxonomy_vocabularies', |
||
| 17 | function (Blueprint $table) { |
||
| 18 | $table->increments('id'); |
||
| 19 | $table->string('name', 255); |
||
| 20 | $table->string('machine_name', 255)->unique(); |
||
| 21 | $table->text('description')->nullable(); |
||
| 22 | $table->integer('hierarchy')->default(0); // 0 = disabled, 1 = single, 2 = multiple |
||
| 23 | $table->integer('translatable')->default(1); |
||
| 24 | } |
||
| 25 | ); |
||
| 26 | |||
| 27 | Schema::create( |
||
| 28 | 'taxonomy_terms', |
||
| 29 | function (Blueprint $table) { |
||
| 30 | $table->increments('id'); |
||
| 31 | $table->unsignedInteger('vocabulary_id'); |
||
| 32 | $table->integer('type')->default(0); // 0 = simple, 1 = category |
||
| 33 | |||
| 34 | $table->foreign('vocabulary_id')->references('id')->on('taxonomy_vocabularies'); |
||
| 35 | } |
||
| 36 | ); |
||
| 37 | |||
| 38 | Schema::create( |
||
| 39 | 'taxonomy_terms_data', |
||
| 40 | function (Blueprint $table) { |
||
| 41 | $table->increments('id'); |
||
| 42 | $table->unsignedInteger('term_id'); |
||
| 43 | $table->unsignedInteger('language_id'); |
||
| 44 | $table->string('title', 255); |
||
| 45 | $table->text('description')->nullable(); |
||
| 46 | |||
| 47 | $table->foreign('term_id')->references('id')->on('taxonomy_terms'); |
||
| 48 | $table->foreign('language_id')->references('id')->on('languages'); |
||
| 49 | } |
||
| 50 | ); |
||
| 51 | |||
| 52 | Schema::create( |
||
| 53 | 'taxonomy_term_hierarchy', |
||
| 54 | function (Blueprint $table) { |
||
| 55 | $table->unsignedInteger('term_id'); |
||
| 56 | $table->unsignedInteger('parent_id'); |
||
| 57 | |||
| 58 | $table->foreign('term_id')->references('id')->on('taxonomy_terms'); |
||
| 59 | $table->foreign('parent_id')->references('id')->on('taxonomy_terms'); |
||
| 60 | |||
| 61 | $table->primary(['term_id', 'parent_id']); |
||
| 62 | } |
||
| 63 | ); |
||
| 64 | |||
| 65 | Schema::create( |
||
| 66 | 'taxonomy_content', |
||
| 67 | function (Blueprint $table) { |
||
| 68 | $table->unsignedInteger('term_id'); |
||
| 69 | $table->unsignedInteger('relationable_id'); |
||
| 70 | $table->string('relationable_type'); |
||
| 71 | |||
| 72 | $table->foreign('term_id')->references('id')->on('taxonomy_terms'); |
||
| 73 | |||
| 74 | $table->primary( |
||
| 75 | ['term_id', 'relationable_id', 'relationable_type'], |
||
| 76 | 'taxonomy_contents_composed_primary' |
||
| 77 | ); |
||
| 78 | } |
||
| 79 | ); |
||
| 80 | } |
||
| 81 | |||
| 96 |