12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
-
- namespace Illuminate\Database;
-
- use Illuminate\Support\ServiceProvider;
- use Illuminate\Database\Migrations\Migrator;
- use Illuminate\Database\Migrations\MigrationCreator;
- use Illuminate\Database\Migrations\DatabaseMigrationRepository;
-
- class MigrationServiceProvider extends ServiceProvider
- {
- /**
- * Indicates if loading of the provider is deferred.
- *
- * @var bool
- */
- protected $defer = true;
-
- /**
- * Register the service provider.
- *
- * @return void
- */
- public function register()
- {
- $this->registerRepository();
-
- $this->registerMigrator();
-
- $this->registerCreator();
- }
-
- /**
- * Register the migration repository service.
- *
- * @return void
- */
- protected function registerRepository()
- {
- $this->app->singleton('migration.repository', function ($app) {
- $table = $app['config']['database.migrations'];
-
- return new DatabaseMigrationRepository($app['db'], $table);
- });
- }
-
- /**
- * Register the migrator service.
- *
- * @return void
- */
- protected function registerMigrator()
- {
- // The migrator is responsible for actually running and rollback the migration
- // files in the application. We'll pass in our database connection resolver
- // so the migrator can resolve any of these connections when it needs to.
- $this->app->singleton('migrator', function ($app) {
- $repository = $app['migration.repository'];
-
- return new Migrator($repository, $app['db'], $app['files']);
- });
- }
-
- /**
- * Register the migration creator.
- *
- * @return void
- */
- protected function registerCreator()
- {
- $this->app->singleton('migration.creator', function ($app) {
- return new MigrationCreator($app['files']);
- });
- }
-
- /**
- * Get the services provided by the provider.
- *
- * @return array
- */
- public function provides()
- {
- return [
- 'migrator', 'migration.repository', 'migration.creator',
- ];
- }
- }
|