CreateMovieEarningsTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 44
ccs 14
cts 20
cp 0.7
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 20 1
A down() 0 9 1
1
<?php
2
3
use Illuminate\Database\Schema\Blueprint;
4
use Illuminate\Database\Migrations\Migration;
5
6
class CreateMovieEarningsTable 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...
7
8
	/**
9
	 * Run the migrations.
10
	 *
11
	 * @return void
12
	 */
13 9
	public function up() {
14
		DB::transaction(function () {
15
			Schema::create('movie_earnings', function (Blueprint $table) {
16 9
				$table->increments('id');
17 9
				$table->unsignedInteger('movie_id');
18 9
				$table->date('date');
19 9
				$table->unsignedBigInteger('domestic')->nullable();
20 9
				$table->unsignedBigInteger('worldwide')->nullable();
21 9
				$table->timestamps();
22
23 9
				$table->foreign('movie_id')->references('id')->on('movies')->onUpdate('cascade')->onDelete('cascade');
24 9
			});
25
26
			Schema::table('movies', function (Blueprint $table) {
27 9
				$table->foreign('latest_earnings_id')->references('id')->on('movie_earnings')->onUpdate('set null')
28 9
				      ->onDelete('cascade');
29 9
			});
30
31 9
		});
32 9
	}
33
34
	/**
35
	 * Reverse the migrations.
36
	 *
37
	 * @return void
38
	 */
39
	public function down() {
40
		DB::transaction(function () {
41
			Schema::table('movies', function (Blueprint $table) {
42
				$table->dropForeign('movies_latest_earnings_id_foreign');
43
			});
44
45
			Schema::drop('movie_earnings');
46
		});
47
	}
48
49
}
50