CreateContactRelationsTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 17 1
A down() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
use Illuminate\Support\Facades\Schema;
6
use Illuminate\Database\Schema\Blueprint;
7
use Illuminate\Database\Migrations\Migration;
8
9
class CreateContactRelationsTable extends Migration
10
{
11
    public function up()
12
    {
13
        Schema::create(config('rinvex.contacts.tables.contact_relations'), function (Blueprint $table) {
14
            // Columns
15
            $table->integer('contact_id')->unsigned();
16
            $table->integer('related_id')->unsigned();
17
            $table->string('relation');
18
            $table->timestamps();
19
20
            // Indexes
21
            $table->primary(['contact_id', 'related_id']);
22
            $table->foreign('contact_id')->references('id')->on(config('rinvex.contacts.tables.contacts'))
23
                  ->onDelete('cascade')->onUpdate('cascade');
24
            $table->foreign('related_id')->references('id')->on(config('rinvex.contacts.tables.contacts'))
25
                  ->onDelete('cascade')->onUpdate('cascade');
26
        });
27
    }
28
29
    public function down()
30
    {
31
        Schema::dropIfExists(config('rinvex.contacts.tables.contact_relations'));
32
    }
33
}
34