Skip to content

Commit 14d3319

Browse files
committed
Improving migration publishing
1 parent 6bb1ec8 commit 14d3319

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/OAuth2ServerServiceProvider.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function register()
4343
$this->registerAssets();
4444
$this->registerAuthorizer();
4545
$this->registerFilterBindings();
46-
$this->registerCommands();
4746
}
4847

4948
/**
@@ -53,10 +52,30 @@ public function register()
5352
public function registerAssets()
5453
{
5554
$configPath = __DIR__ . '/../config/oauth2.php';
56-
$migrationsPath = __DIR__ . '/../migrations';
55+
$mFrom = __DIR__ . '/../migrations/';
56+
$mTo = $this->app['path.database'] . '/migrations/';
5757
$this->mergeConfigFrom($configPath, 'oauth2');
5858
$this->publishes([$configPath => config_path('oauth2.php')], 'config');
59-
$this->publishes([$migrationsPath => $this->app['path.database'] . '/migrations'], 'migrations');
59+
$this->publishes([
60+
$mFrom . '2014_04_24_110304_create_oauth_grants_table.php' => $mTo . $this->ts(1) . 'create_oauth_grants_table.php',
61+
$mFrom . '2014_04_24_110403_create_oauth_grant_scopes_table.php' => $mTo . $this->ts(2) . 'create_oauth_grant_scopes_table.php',
62+
$mFrom . '2014_04_24_110459_create_oauth_clients_table.php' => $mTo . $this->ts(3) . 'create_oauth_clients_table.php',
63+
$mFrom . '2014_04_24_110557_create_oauth_client_endpoints_table.php' => $mTo . $this->ts(4) . 'create_oauth_client_endpoints_table.php',
64+
$mFrom . '2014_04_24_110705_create_oauth_client_scopes_table.php' => $mTo . $this->ts(5) . 'create_oauth_client_scopes_table.php',
65+
$mFrom . '2014_04_24_110817_create_oauth_client_grants_table.php' => $mTo . $this->ts(6) . 'create_oauth_client_grants_table.php',
66+
$mFrom . '2014_04_24_111002_create_oauth_sessions_table.php' => $mTo . $this->ts(7) . 'create_oauth_sessions_table.php',
67+
$mFrom . '2014_04_24_111109_create_oauth_session_scopes_table.php' => $mTo . $this->ts(8) . 'create_oauth_session_scopes_table.php',
68+
$mFrom . '2014_04_24_111254_create_oauth_auth_codes_table.php' => $mTo . $this->ts(9) . 'create_oauth_auth_codes_table.php',
69+
$mFrom . '2014_04_24_111403_create_oauth_auth_code_scopes_table.php' => $mTo . $this->ts(10) . 'create_oauth_auth_code_scopes_table.php',
70+
$mFrom . '2014_04_24_111518_create_oauth_access_tokens_table.php' => $mTo . $this->ts(11) . 'create_oauth_access_tokens_table.php',
71+
$mFrom . '2014_04_24_111657_create_oauth_access_token_scopes_table.php' => $mTo . $this->ts(12) . 'create_oauth_access_token_scopes_table.php',
72+
$mFrom . '2014_04_24_111810_create_oauth_refresh_tokens_table.php' => $mTo . $this->ts(13) . 'create_oauth_refresh_tokens_table.php',
73+
], 'migrations');
74+
}
75+
76+
protected function ts($seconds)
77+
{
78+
return Carbon::now()->addSecond($seconds)->toDateString()->format('Y_m_d_His').'_';
6079
}
6180

6281
/**
@@ -144,19 +163,6 @@ public function provides()
144163
return ['oauth2-server.authorizer'];
145164
}
146165

147-
/**
148-
* Registers some utility commands with artisan
149-
* @return void
150-
*/
151-
public function registerCommands()
152-
{
153-
$this->app->bind('command.oauth2-server.controller', 'LucaDegasperi\OAuth2Server\Console\OAuthControllerCommand');
154-
$this->app->bind('command.oauth2-server.migrations', 'LucaDegasperi\OAuth2Server\Console\MigrationsCommand');
155-
$this->app->bind('command.oauth2-server.client.create', 'LucaDegasperi\OAuth2Server\Console\ClientCreatorCommand');
156-
157-
$this->commands('command.oauth2-server.controller', 'command.oauth2-server.migrations', 'command.oauth2-server.client.create');
158-
}
159-
160166
/**
161167
* Boot the filters
162168
* @return void
@@ -166,6 +172,5 @@ private function bootFilters()
166172
$this->app['router']->filter('check-authorization-params', 'LucaDegasperi\OAuth2Server\Filters\CheckAuthCodeRequestFilter');
167173
$this->app['router']->filter('oauth', 'LucaDegasperi\OAuth2Server\Filters\OAuthFilter');
168174
$this->app['router']->filter('oauth-owner', 'LucaDegasperi\OAuth2Server\Filters\OAuthOwnerFilter');
169-
$this->app['router']->middleware('LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware');
170175
}
171176
}

0 commit comments

Comments
 (0)