1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Support\Facades\Schema; |
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
5
|
|
|
use Illuminate\Database\Migrations\Migration; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class CreateDepartmentsTable. |
9
|
|
|
*/ |
10
|
|
|
class CreateDepartmentsTable extends Migration |
|
|
|
|
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Run the migrations. |
14
|
|
|
* |
15
|
|
|
* @return void |
16
|
|
|
*/ |
17
|
|
|
public function up() |
18
|
|
|
{ |
19
|
|
View Code Duplication |
Schema::create('departments', function (Blueprint $table) { |
|
|
|
|
20
|
|
|
$table->increments('id'); |
21
|
|
|
$table->string('name'); |
22
|
|
|
$table->integer('parent')->unsigned()->nullable(); |
23
|
|
|
$table->integer('location_id')->unsigned(); |
24
|
|
|
$table->timestamps(); |
25
|
|
|
}); |
26
|
|
|
Schema::create('department_family', function (Blueprint $table) { |
|
|
|
|
27
|
|
|
$table->integer('department_id')->unsigned(); |
28
|
|
|
$table->integer('family_id')->unsigned(); |
29
|
|
|
$table->timestamps(); |
30
|
|
|
$table->unique(['department_id', 'family_id']); |
31
|
|
|
}); |
32
|
|
|
Schema::create('department_head', function (Blueprint $table) { |
|
|
|
|
33
|
|
|
$table->integer('department_id')->unsigned(); |
34
|
|
|
$table->integer('user_id')->unsigned(); |
35
|
|
|
$table->boolean('main')->default(false); |
36
|
|
|
$table->timestamps(); |
37
|
|
|
$table->unique(['department_id', 'user_id']); |
38
|
|
|
}); |
39
|
|
|
Schema::create('department_study', function (Blueprint $table) { |
|
|
|
|
40
|
|
|
$table->integer('department_id')->unsigned(); |
41
|
|
|
$table->integer('study_id')->unsigned(); |
42
|
|
|
$table->timestamps(); |
43
|
|
|
$table->unique(['department_id', 'study_id']); |
44
|
|
|
}); |
45
|
|
|
} |
46
|
|
|
/** |
47
|
|
|
* Reverse the migrations. |
48
|
|
|
* |
49
|
|
|
* @return void |
50
|
|
|
*/ |
51
|
|
|
public function down() |
52
|
|
|
{ |
53
|
|
|
Schema::dropIfExists('departments'); |
54
|
|
|
Schema::dropIfExists('department_family'); |
55
|
|
|
Schema::dropIfExists('department_head'); |
56
|
|
|
Schema::dropIfExists('department_study'); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.