Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Code Lines | 41 |
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 |
||
15 | public function up(): void |
||
16 | { |
||
17 | Schema::create('blog_etc_posts', static function (Blueprint $table) { |
||
18 | $table->increments('id'); |
||
19 | |||
20 | $table->string('slug')->unique(); |
||
21 | $table->unsignedInteger('user_id')->index()->nullable(); |
||
22 | $table->string('title')->nullable()->default('New blog post'); |
||
23 | $table->string('subtitle')->nullable()->default(''); |
||
24 | $table->text('meta_desc')->nullable(); |
||
25 | $table->mediumText('post_body')->nullable(); |
||
26 | $table->string('use_view_file') |
||
27 | ->nullable() |
||
28 | ->comment('If not null, this should refer to a blade file in /views/'); |
||
29 | $table->dateTime('posted_at')->index()->nullable() |
||
30 | ->comment('Public posted at time, if this is in future then it wont appear yet'); |
||
31 | $table->boolean('is_published')->default(true); |
||
32 | $table->string('image_large')->nullable(); |
||
33 | $table->string('image_medium')->nullable(); |
||
34 | $table->string('image_thumbnail')->nullable(); |
||
35 | |||
36 | $table->timestamps(); |
||
37 | }); |
||
38 | |||
39 | Schema::create('blog_etc_categories', static function (Blueprint $table) { |
||
40 | $table->increments('id'); |
||
41 | |||
42 | $table->string('category_name')->nullable(); |
||
43 | $table->string('slug')->unique(); |
||
44 | $table->mediumText('category_description')->nullable(); |
||
45 | $table->unsignedInteger('created_by')->nullable()->index()->comment('user id'); |
||
46 | |||
47 | $table->timestamps(); |
||
48 | }); |
||
49 | |||
50 | // linking table: |
||
51 | Schema::create('blog_etc_post_categories', static function (Blueprint $table) { |
||
52 | $table->increments('id'); |
||
53 | |||
54 | $table->unsignedInteger('blog_etc_post_id')->index(); |
||
55 | $table->foreign('blog_etc_post_id')->references('id')->on('blog_etc_posts')->onDelete('cascade'); |
||
56 | $table->unsignedInteger('blog_etc_category_id')->index(); |
||
57 | |||
58 | $table->foreign('blog_etc_category_id')->references('id')->on('blog_etc_categories')->onDelete('cascade'); |
||
59 | }); |
||
60 | |||
61 | Schema::create('blog_etc_comments', static function (Blueprint $table) { |
||
62 | $table->increments('id'); |
||
63 | |||
64 | $table->unsignedInteger('blog_etc_post_id')->index(); |
||
65 | $table->foreign('blog_etc_post_id')->references('id')->on('blog_etc_posts')->onDelete('cascade'); |
||
66 | $table->unsignedInteger('user_id')->nullable()->index()->comment('if user was logged in'); |
||
67 | $table->string('ip')->nullable()->comment('if enabled in the config file'); |
||
68 | $table->string('author_name')->nullable()->comment('if not logged in'); |
||
69 | $table->text('comment')->comment('the comment body'); |
||
70 | $table->boolean('approved')->default(true); |
||
71 | |||
72 | $table->timestamps(); |
||
73 | }); |
||
87 |