| @@ 7-40 (lines=34) @@ | ||
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | use Illuminate\Database\Migrations\Migration; |
|
| 6 | ||
| 7 | class CreatePermissionRoleTable extends Migration |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Run the migrations. |
|
| 11 | * |
|
| 12 | * @return void |
|
| 13 | */ |
|
| 14 | public function up() |
|
| 15 | { |
|
| 16 | if (config('multi-tenant.use_roles_and_permissions')) { |
|
| 17 | Schema::create('multi_tenant_permission_multi_tenant_role', function (Blueprint $table) { |
|
| 18 | $table->increments('id'); |
|
| 19 | $table->integer('multi_tenant_role_id')->unsigned(); |
|
| 20 | $table->integer('multi_tenant_permission_id')->unsigned(); |
|
| 21 | $table->timestamps(); |
|
| 22 | ||
| 23 | $table->index('multi_tenant_permission_id', 'permission_role_permission_id_index'); |
|
| 24 | $table->index('multi_tenant_role_id', 'permission_role_role_id_index'); |
|
| 25 | }); |
|
| 26 | } |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Reverse the migrations. |
|
| 31 | * |
|
| 32 | * @return void |
|
| 33 | */ |
|
| 34 | public function down() |
|
| 35 | { |
|
| 36 | if (config('multi-tenant.use_roles_and_permissions')) { |
|
| 37 | Schema::dropIfExists('multi_tenant_permission_multi_tenant_role'); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||
| @@ 7-41 (lines=35) @@ | ||
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | use Illuminate\Database\Migrations\Migration; |
|
| 6 | ||
| 7 | class CreatePermissionsTable extends Migration |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Run the migrations. |
|
| 11 | * |
|
| 12 | * @return void |
|
| 13 | */ |
|
| 14 | public function up() |
|
| 15 | { |
|
| 16 | if (config('multi-tenant.use_roles_and_permissions')) { |
|
| 17 | Schema::create('multi_tenant_permissions', function (Blueprint $table) { |
|
| 18 | $table->increments('id'); |
|
| 19 | $table->integer('feature_id')->nullable(); |
|
| 20 | $table->string('name'); |
|
| 21 | $table->string('label')->nullable(); |
|
| 22 | $table->text('description')->nullable(); |
|
| 23 | $table->timestamps(); |
|
| 24 | ||
| 25 | $table->index('feature_id', 'permissions_feature_id_index'); |
|
| 26 | }); |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Reverse the migrations. |
|
| 32 | * |
|
| 33 | * @return void |
|
| 34 | */ |
|
| 35 | public function down() |
|
| 36 | { |
|
| 37 | if (config('multi-tenant.use_roles_and_permissions')) { |
|
| 38 | Schema::dropIfExists('multi_tenant_permissions'); |
|
| 39 | } |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||
| @@ 7-40 (lines=34) @@ | ||
| 4 | use Illuminate\Database\Schema\Blueprint; |
|
| 5 | use Illuminate\Database\Migrations\Migration; |
|
| 6 | ||
| 7 | class CreateRoleUserTable extends Migration |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Run the migrations. |
|
| 11 | * |
|
| 12 | * @return void |
|
| 13 | */ |
|
| 14 | public function up() |
|
| 15 | { |
|
| 16 | if (config('multi-tenant.use_roles_and_permissions')) { |
|
| 17 | Schema::create('multi_tenant_role_user', function (Blueprint $table) { |
|
| 18 | $table->increments('id'); |
|
| 19 | $table->integer('multi_tenant_role_id')->unsigned(); |
|
| 20 | $table->integer('user_id')->unsigned(); |
|
| 21 | $table->timestamps(); |
|
| 22 | ||
| 23 | $table->index('multi_tenant_role_id', 'role_user_role_id_index'); |
|
| 24 | $table->index('user_id', 'role_user_user_id_index'); |
|
| 25 | }); |
|
| 26 | } |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Reverse the migrations. |
|
| 31 | * |
|
| 32 | * @return void |
|
| 33 | */ |
|
| 34 | public function down() |
|
| 35 | { |
|
| 36 | if (config('multi-tenant.use_roles_and_permissions')) { |
|
| 37 | Schema::dropIfExists('multi_tenant_role_user'); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | } |
|
| 41 | ||