| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 47 |
| 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 |
||
| 14 | public function up() |
||
| 15 | { |
||
| 16 | Schema::create('news', function (Blueprint $table) { |
||
| 17 | $table->increments('id'); |
||
| 18 | $table->string('title')->nullable(); |
||
| 19 | $table->text('short_description')->nullable(); |
||
| 20 | $table->text('content')->nullable(); |
||
| 21 | $table->string('meta_title')->nullable(); |
||
| 22 | $table->string('meta_description')->nullable(); |
||
| 23 | $table->string('meta_keywords')->nullable(); |
||
| 24 | $table->string('slug'); |
||
| 25 | $table->date('published_at')->nullable(); |
||
| 26 | $table->integer('shop_id')->unsigned()->nullable(); |
||
| 27 | $table->foreign('shop_id')->references('id')->on('shop')->onDelete('cascade'); |
||
| 28 | $table->integer('modified_by_user_id')->unsigned()->nullable(); |
||
| 29 | $table->foreign('modified_by_user_id')->references('id')->on('user')->onDelete('set null'); |
||
| 30 | $table->timestamps(); |
||
| 31 | $table->unique(array('title','shop_id'), 'unique_news_title'); |
||
| 32 | }); |
||
| 33 | |||
| 34 | |||
| 35 | Schema::create('news_image', function (Blueprint $table) { |
||
| 36 | $table->increments('id'); |
||
| 37 | $table->integer('news_id')->unsigned(); |
||
| 38 | $table->foreign('news_id')->references('id')->on('news')->onDelete('cascade'); |
||
| 39 | $table->string('file')->nullable(); |
||
| 40 | $table->string('path')->nullable(); |
||
| 41 | $table->integer('size')->nullable(); |
||
| 42 | $table->string('extension')->nullable(); |
||
| 43 | $table->integer('rank')->default(0); |
||
| 44 | $table->string('tag')->nullable(); |
||
| 45 | $table->integer('modified_by_user_id')->unsigned()->nullable(); |
||
| 46 | $table->foreign('modified_by_user_id')->references('id')->on('user')->onDelete('set null'); |
||
| 47 | $table->timestamps(); |
||
| 48 | }); |
||
| 49 | |||
| 50 | // Creates the users table |
||
| 51 | Schema::create('news_group', function ($table) { |
||
| 52 | $table->increments('id'); |
||
| 53 | $table->boolean('active')->default(false); |
||
| 54 | $table->integer('rank')->default(0); |
||
| 55 | $table->string('title'); |
||
| 56 | $table->string('meta_title')->nullable(); |
||
| 57 | $table->string('meta_description')->nullable(); |
||
| 58 | $table->string('meta_keywords')->nullable(); |
||
| 59 | $table->string('slug'); |
||
| 60 | $table->integer('shop_id')->unsigned(); |
||
| 61 | $table->foreign('shop_id')->references('id')->on('shop')->onDelete('cascade'); |
||
| 62 | $table->integer('modified_by_user_id')->unsigned()->nullable(); |
||
| 63 | $table->foreign('modified_by_user_id')->references('id')->on('user')->onDelete('set null'); |
||
| 64 | $table->unique(array('title','shop_id'), 'unique_news_group_title'); |
||
| 65 | $table->timestamps(); |
||
| 66 | }); |
||
| 67 | |||
| 68 | |||
| 69 | Schema::table('news', function (Blueprint $table) { |
||
| 70 | $table->integer('news_group_id')->unsigned()->nullable(); |
||
| 71 | $table->foreign('news_group_id')->references('id')->on('news_group')->onDelete('set null'); |
||
| 72 | }); |
||
| 86 |