Passed
Push — master ( 2c3721...94fb22 )
by Grant
09:10 queued 10s
created

MakeCourseTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 21
dl 0
loc 43
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class MakeCourseTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('courses', function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->string('name')->nullable();
19
            $table->string('institution')->nullable();
20
            $table->integer('course_status_id')->unsigned()->nullable();
21
            $table->date('start_date')->nullable();
22
            $table->date('end_date')->nullable();
23
            $table->integer('applicant_id')->unsigned();
24
            $table->timestamps();
25
        });
26
27
        Schema::create('course_status', function (Blueprint $table) {
28
           $table->increments('id');
29
           $table->string('name');
30
           $table->timestamps();
31
        });
32
33
        Schema::table('courses', function (Blueprint $table) {
34
            $table->foreign('course_status_id')->references('id')->
35
                on('course_status')->onUpdate('CASCADE')->onDelete('NO ACTION');
36
            $table->foreign('applicant_id')->references('id')->
37
                on('applicants')->onUpdate('CASCADE')->onDelete('CASCADE');
38
        });
39
    }
40
41
    /**
42
     * Reverse the migrations.
43
     *
44
     * @return void
45
     */
46
    public function down()
47
    {
48
        Schema::dropIfExists('courses');
49
        Schema::dropIfExists('course_status');
50
    }
51
}
52