diff --git a/src/Illuminate/Database/MigrationServiceProvider.php b/src/Illuminate/Database/MigrationServiceProvider.php index 779e19fdc120..5c709acb0ebc 100755 --- a/src/Illuminate/Database/MigrationServiceProvider.php +++ b/src/Illuminate/Database/MigrationServiceProvider.php @@ -78,7 +78,7 @@ protected function registerMigrator() $this->app->singleton('migrator', function ($app) { $repository = $app['migration.repository']; - return new Migrator($repository, $app['db'], $app['files'], $app['events']); + return new Migrator($repository, $app['db'], $app['files'], $app['events'], $app); }); } diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php index d3dab9db9472..2ea263b71dca 100755 --- a/src/Illuminate/Database/Migrations/Migrator.php +++ b/src/Illuminate/Database/Migrations/Migrator.php @@ -3,6 +3,7 @@ namespace Illuminate\Database\Migrations; use Illuminate\Collections\Arr; +use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Database\ConnectionResolverInterface as Resolver; use Illuminate\Database\Events\MigrationEnded; @@ -18,18 +19,18 @@ class Migrator { /** - * The event dispatcher instance. + * The migration repository implementation. * - * @var \Illuminate\Contracts\Events\Dispatcher + * @var \Illuminate\Database\Migrations\MigrationRepositoryInterface */ - protected $events; + protected $repository; /** - * The migration repository implementation. + * The connection resolver instance. * - * @var \Illuminate\Database\Migrations\MigrationRepositoryInterface + * @var \Illuminate\Database\ConnectionResolverInterface */ - protected $repository; + protected $resolver; /** * The filesystem instance. @@ -39,11 +40,18 @@ class Migrator protected $files; /** - * The connection resolver instance. + * The event dispatcher instance. * - * @var \Illuminate\Database\ConnectionResolverInterface + * @var \Illuminate\Contracts\Events\Dispatcher */ - protected $resolver; + protected $events; + + /** + * The container implementation. + * + * @var \Illuminate\Contracts\Container\Container|null + */ + protected $container; /** * The name of the default connection. @@ -73,17 +81,20 @@ class Migrator * @param \Illuminate\Database\ConnectionResolverInterface $resolver * @param \Illuminate\Filesystem\Filesystem $files * @param \Illuminate\Contracts\Events\Dispatcher|null $dispatcher + * @param \Illuminate\Contracts\Container\Container|null $container * @return void */ public function __construct(MigrationRepositoryInterface $repository, Resolver $resolver, Filesystem $files, - Dispatcher $dispatcher = null) + Dispatcher $dispatcher = null, + Container $container = null) { + $this->repository = $repository; + $this->resolver = $resolver; $this->files = $files; $this->events = $dispatcher; - $this->resolver = $resolver; - $this->repository = $repository; + $this->container = $container; } /** @@ -450,7 +461,11 @@ public function resolve($file) { $class = Str::studly(implode('_', array_slice(explode('_', $file), 4))); - return new $class; + if (is_null($this->container)) { + return new $class; + } + + return $this->container->make($class); } /**