CreateForeignKeys::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Eloquent\Model;
6
7
class CreateForeignKeys 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
	public function up()
10
	{
11
		Schema::table('pdrb_harga_dasars', function(Blueprint $table) {
12
			$table->foreign('province_id')->references('id')->on('provinces')
13
						->onDelete('set null')
14
						->onUpdate('restrict');
15
		});
16
		Schema::table('pdrb_harga_dasars', function(Blueprint $table) {
17
			$table->foreign('regency_id')->references('id')->on('regencies')
18
						->onDelete('set null')
19
						->onUpdate('restrict');
20
		});
21
		Schema::table('regencies', function(Blueprint $table) {
22
			$table->foreign('province_id')->references('id')->on('provinces')
23
						->onDelete('set null')
24
						->onUpdate('restrict');
25
		});
26
	}
27
28
	public function down()
29
	{
30
		Schema::table('pdrb_harga_dasars', function(Blueprint $table) {
31
			$table->dropForeign('pdrb_harga_dasars_province_id_foreign');
32
		});
33
		Schema::table('pdrb_harga_dasars', function(Blueprint $table) {
34
			$table->dropForeign('pdrb_harga_dasars_regency_id_foreign');
35
		});
36
		Schema::table('regencies', function(Blueprint $table) {
37
			$table->dropForeign('regencies_province_id_foreign');
38
		});
39
	}
40
}