Skip to content

Instantly share code, notes, and snippets.

@filipedanielski
Created September 19, 2019 20:54
Show Gist options
  • Select an option

  • Save filipedanielski/9294baf32a74df82f1a44d5d41f75e9f to your computer and use it in GitHub Desktop.

Select an option

Save filipedanielski/9294baf32a74df82f1a44d5d41f75e9f to your computer and use it in GitHub Desktop.
<?php
namespace WF5\Muse\Core\Providers;
use WF5\Muse\Core\Database\Migrator;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Support\DeferrableProvider;
class NamespacedMigrationServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerMigrator();
}
/**
* 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->extend('migrator', function ($service, $app) {
$repository = $app['migration.repository'];
return new Migrator($repository, $app['db'], $app['files'], $app['events']);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [
'migrator'
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment