Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Database/MigrationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down
41 changes: 28 additions & 13 deletions src/Illuminate/Database/Migrations/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down