1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use jlourenco\base\Database\Blueprint; |
4
|
|
|
use Illuminate\Database\Migrations\Migration; |
5
|
|
|
|
6
|
|
|
class CreateMenuTables extends Migration |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Run the migrations. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function up() |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
Schema::create('Menu', function (Blueprint $table) { |
18
|
|
|
$table->increments('id'); |
19
|
|
|
$table->string('name', 50); |
20
|
|
|
$table->integer('pos')->unsigned(); |
21
|
|
|
|
22
|
|
|
$table->timestamps(); |
23
|
|
|
$table->softDeletes(); |
24
|
|
|
$table->creation(); |
25
|
|
|
}); |
26
|
|
|
|
27
|
|
|
Schema::create('Page', function (Blueprint $table) { |
28
|
|
|
$table->increments('id'); |
29
|
|
|
$table->string('name', 50); |
30
|
|
|
$table->string('url', 250); |
31
|
|
|
$table->string('target', 25); |
32
|
|
|
$table->string('icon', 250); |
33
|
|
|
$table->text('contents')->nullable(); |
34
|
|
|
|
35
|
|
|
$table->timestamps(); |
36
|
|
|
$table->softDeletes(); |
37
|
|
|
$table->creation(); |
38
|
|
|
}); |
39
|
|
|
|
40
|
|
|
Schema::create('Menu_Page', function (Blueprint $table) { |
41
|
|
|
$table->increments('id'); |
42
|
|
|
$table->integer('menu')->unsigned(); |
43
|
|
|
$table->integer('page')->unsigned(); |
44
|
|
|
$table->integer('father')->unsigned()->nullable(); |
45
|
|
|
$table->integer('order'); |
46
|
|
|
|
47
|
|
|
$table->foreign('menu')->references('id')->on('Menu'); |
48
|
|
|
$table->foreign('page')->references('id')->on('Page'); |
49
|
|
|
$table->foreign('father')->references('id')->on('Page'); |
50
|
|
|
}); |
51
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Reverse the migrations. |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
public function down() |
60
|
|
|
{ |
61
|
|
|
|
62
|
|
|
Schema::drop('Menu_Page'); |
63
|
|
|
Schema::drop('Menu'); |
64
|
|
|
Schema::drop('Page'); |
65
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
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.