Passed
Pull Request — dev (#313)
by Tristan
06:51
created

CreateReferencesTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 15
dl 0
loc 35
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 17 1
A down() 0 3 1
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreateReferencesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('references', function (Blueprint $table) {
17
            $table->increments('id');
18
			$table->string('name')->nullable();
19
			$table->string('email')->nullable();
20
			$table->integer('relationship_id')->unsigned()->nullable();
21
			$table->text('description')->nullable();
22
            $table->integer('applicant_id')->unsigned();
23
			$table->timestamps();
24
        });
25
26
        Schema::table('references', function (Blueprint $table) {
27
            $table->foreign('applicant_id')->references('id')->
28
                on('applicants')->onUpdate('CASCADE')->onDelete('CASCADE');
29
            $table->foreign('relationship_id')->references('id')
30
                ->on('relationships')->onUpdate('CASCADE')->onDelete('NO ACTION');
31
        });
32
    }
33
34
    /**
35
     * Reverse the migrations.
36
     *
37
     * @return void
38
     */
39
    public function down()
40
    {
41
        Schema::dropIfExists('references');
42
    }
43
}
44