| Total Complexity | 2 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class CreateRoleUserTable extends Migration |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Run the migrations. |
||
| 11 | * |
||
| 12 | * @return void |
||
| 13 | */ |
||
| 14 | public function up() |
||
| 15 | { |
||
| 16 | Schema::create('role_user', function (Blueprint $table) { |
||
| 17 | $pkMethod = config('rakshak.users.pk_type', 'uuid'); |
||
| 18 | // dd('pkMethod: ' . $pkMethod); |
||
| 19 | |||
| 20 | $table->{$pkMethod}('user_id'); |
||
| 21 | $table->uuid('role_id'); |
||
| 22 | $table->timestamps(); |
||
| 23 | |||
| 24 | $table->foreign('user_id') |
||
| 25 | ->references('id') |
||
| 26 | ->on('users') |
||
| 27 | ->onDelete('cascade'); |
||
| 28 | |||
| 29 | $table->foreign('role_id') |
||
| 30 | ->references('id') |
||
| 31 | ->on('roles') |
||
| 32 | ->onDelete('cascade'); |
||
| 33 | |||
| 34 | $table->primary(['user_id', 'role_id']); |
||
| 35 | }); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Reverse the migrations. |
||
| 40 | * |
||
| 41 | * @return void |
||
| 42 | */ |
||
| 43 | public function down() |
||
| 46 | } |
||
| 47 | } |
||
| 48 |