Total Complexity | 2 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class CreatePermissionsTable extends Migration |
||
8 | { |
||
9 | /** |
||
10 | * Run the migrations. |
||
11 | * |
||
12 | * @return void |
||
13 | */ |
||
14 | public function up() |
||
15 | { |
||
16 | Schema::create($this->tablePrefix.'permissions', function(Blueprint $table) { |
||
17 | $table->increments('id'); |
||
18 | $table->unsignedInteger('module_id'); |
||
19 | $table->unsignedInteger('profile_id'); |
||
20 | $table->unsignedInteger('capability_id'); |
||
21 | $table->timestamps(); |
||
22 | |||
23 | // Foreign keys |
||
24 | $table->foreign('module_id') |
||
25 | ->references('id')->on($this->tablePrefix.'modules') |
||
26 | ->onDelete('cascade'); |
||
27 | |||
28 | $table->foreign('profile_id') |
||
29 | ->references('id')->on($this->tablePrefix.'profiles') |
||
30 | ->onDelete('cascade'); |
||
31 | |||
32 | $table->foreign('capability_id') |
||
33 | ->references('id')->on($this->tablePrefix.'capabilities') |
||
34 | ->onDelete('cascade'); |
||
35 | |||
36 | // Unique keys |
||
37 | $table->unique([ 'module_id', 'profile_id', 'capability_id' ]); |
||
38 | }); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Reverse the migrations. |
||
43 | * |
||
44 | * @return void |
||
45 | */ |
||
46 | public function down() |
||
49 | } |
||
50 | } |
||
51 |