Completed
Push — master ( 02c616...876046 )
by Joao
03:16
created

CreateBlogTables   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 54
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B up() 0 33 1
A down() 0 7 1
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\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('description', 250);
20
21
            $table->timestamps();
22
            $table->softDeletes();
23
            $table->creation();
24
        });
25
26
        Schema::create('BlogPost', function (Blueprint $table) {
27
            $table->increments('id');
28
            $table->string('title', 100);
29
            $table->text('contents');
30
            $table->integer('category')->unsigned();
31
            $table->integer('author')->unsigned();
32
            $table->integer('likes')->default(0);
33
            $table->integer('shares')->default(0);
34
            $table->integer('views')->default(0);
35
            $table->string('keywords', 250);
36
37
            $table->timestamps();
38
            $table->softDeletes();
39
            $table->creation();
40
41
            $table->foreign('category')->references('id')->on('BlogCategory');
42
            $table->foreign('author')->references('id')->on('User');
43
        });
44
45
    }
46
47
    /**
48
     * Reverse the migrations.
49
     *
50
     * @return void
51
     */
52
    public function down()
53
    {
54
55
        Schema::drop('BlogPost');
56
        Schema::drop('BlogCategory');
57
58
    }
59
}
60