CreateBlogTables::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use \jlourenco\support\Database\Blueprint;
5
6
class CreateBlogTables extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    /**
9
     * Run the migrations.
10
     *
11
     * @return void
12
     */
13
    public function up()
14
    {
15
16
        Schema::create('BlogCategory', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->string('name', 100);
19
            $table->string('slug', 100);
20
            $table->string('description', 250);
21
22
            $table->timestamps();
23
            $table->softDeletes();
24
            $table->creation();
25
        });
26
27
        Schema::table('BlogCategory', function (Blueprint $table) {
28
            $table->creationRelation();
29
        });
30
31
        Schema::create('BlogPost', function (Blueprint $table) {
32
            $table->increments('id');
33
            $table->string('title', 100);
34
            $table->string('slug', 100);
35
            $table->text('contents');
36
            $table->integer('category')->unsigned();
37
            $table->integer('author')->unsigned();
38
            $table->integer('likes')->default(0);
39
            $table->integer('shares')->default(0);
40
            $table->integer('views')->default(0);
41
            $table->string('keywords', 250);
42
43
            $table->timestamps();
44
            $table->softDeletes();
45
            $table->creation();
46
47
            $table->foreign('category')->references('id')->on('BlogCategory');
48
            $table->foreign('author')->references('id')->on('User');
49
        });
50
51
        Schema::table('BlogPost', function (Blueprint $table) {
52
            $table->creationRelation();
53
        });
54
55
    }
56
57
    /**
58
     * Reverse the migrations.
59
     *
60
     * @return void
61
     */
62
    public function down()
63
    {
64
65
        Schema::drop('BlogPost');
66
        Schema::drop('BlogCategory');
67
68
    }
69
}
70