Skip to content

Commit b1db83f

Browse files
authored
Merge pull request #81 from ekawas/migrations-toggle
migrations-toggle: re: issue 76 & 40
2 parents 4f047b5 + 64f8b71 commit b1db83f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ ROLES_PERMISSION_USER_DATABASE_TABLE=permission_user
1414
# Roles Misc Settings
1515
ROLES_DEFAULT_SEPARATOR='.'
1616

17+
# Roles Database Migrations Settings
18+
ROLES_MIGRATION_DEFAULT_ENABLED=true
19+
1720
# Roles Database Seeder Settings
1821
ROLES_SEED_DEFAULT_PERMISSIONS=true
1922
ROLES_SEED_DEFAULT_ROLES=true

src/RolesServiceProvider.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,21 @@ public function boot()
4949
public function register()
5050
{
5151
$this->mergeConfigFrom(__DIR__.'/config/roles.php', 'roles');
52-
$this->loadMigrationsFrom(__DIR__.'/Database/Migrations');
52+
$this->loadMigrations();
5353
if (config('roles.rolesGuiEnabled')) {
5454
$this->loadViewsFrom(__DIR__.'/resources/views/', $this->_packageTag);
5555
}
5656
$this->publishFiles();
5757
$this->loadSeedsFrom();
5858
}
5959

60+
private function loadMigrations()
61+
{
62+
if (config('roles.defaultMigrations.enabled')) {
63+
$this->loadMigrationsFrom(__DIR__.'/Database/Migrations');
64+
}
65+
}
66+
6067
/**
6168
* Loads a seeds.
6269
*

src/config/roles.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,20 @@
6969
'allowed' => true,
7070
],
7171
],
72+
/*
73+
|--------------------------------------------------------------------------
74+
| Default Migrations
75+
|--------------------------------------------------------------------------
76+
|
77+
| These are the default package migrations. If you publish the migrations
78+
| to your project, then this is not necessary and should be disabled. This
79+
| will enable our default migrations.
80+
|
81+
*/
7282

83+
'defaultMigrations' => [
84+
'enabled' => env('ROLES_MIGRATION_DEFAULT_ENABLED', false),
85+
],
7386
/*
7487
|--------------------------------------------------------------------------
7588
| Default Seeds

0 commit comments

Comments
 (0)