CreateForeignKeyVueGuard::up()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 19
nc 1
nop 0
dl 0
loc 25
rs 8.8571
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 CreateForeignKeyVueGuard 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...
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {               
16
        Schema::table('workflow_guards', function(Blueprint $table){
17
            $table->foreign('workflow_id')
18
            ->references('id')
19
            ->on('workflows')
20
            ->onDelete('set null')
21
            ->onUpdate('restrict');
22
        });
23
        Schema::table('workflow_guards', function(Blueprint $table){
24
            $table->foreign('transition_id')
25
            ->references('id')
26
            ->on('workflow_transition')
27
            ->onDelete('set null')
28
            ->onUpdate('restrict');
29
        });
30
        Schema::table('workflow_guards', function(Blueprint $table){
31
            $table->foreign('permission_id')
32
            ->references('id')
33
            ->on('permissions')
34
            ->onDelete('set null')
35
            ->onUpdate('restrict');
36
        });
37
        
38
    }
39
40
    /**
41
     * Reverse the migrations.
42
     *
43
     * @return void
44
     */
45
    public function down()
46
    {
47
        Schema::table('workflow_guards', function(Blueprint $table) {
48
            $table->dropForeign('workflow_guards_workflow_id_foreign');         
49
        });
50
        Schema::table('workflow_guards', function(Blueprint $table) {
51
            $table->dropForeign('workflow_guards_transition_id_foreign');         
52
        });
53
        Schema::table('workflow_guards', function(Blueprint $table) {
54
            $table->dropForeign('workflow_guards_permission_id_foreign');         
55
        });
56
    }
57
}
58