Completed
Pull Request — master (#372)
by Mike
31:01 queued 16:07
created

CreateBooks   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A up() 0 25 1
1
<?php
2
3
use Illuminate\Database\Schema\Blueprint;
4
use Illuminate\Database\Migrations\Migration;
5
6
class CreateBooks extends Migration
7
{
8
    public function up()
9
    {
10
        Schema::create('books', function (Blueprint $table) {
11
            $table->increments('id');
12
            $table->unsignedInteger('author_id');
13
            $table->unsignedInteger('publisher_id');
14
            $table->timestamps();
15
16
            $table->text('description')->nullable();
17
            $table->dateTime('published_at');
18
            $table->string('title');
19
            $table->decimal('price')->default(0);
20
21
            $table->foreign('author_id')
22
                ->references('id')
23
                ->on('authors')
24
                ->onUpdate('CASCADE')
25
                ->onDelete('CASCADE');
26
            $table->foreign('publisher_id')
27
                ->references('id')
28
                ->on('publishers')
29
                ->onUpdate('CASCADE')
30
                ->onDelete('CASCADE');
31
        });
32
    }
33
}
34