Skip to content

Commit

Permalink
[5.8] Register binding for schema facade (#25512)
Browse files Browse the repository at this point in the history
* Register binding for schema builder

* Use new service binding in Schema facade
  • Loading branch information
franzliedke authored and taylorotwell committed Sep 7, 2018
1 parent c0c022e commit 0dd0c63
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Database/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ protected function registerConnectionServices()
$this->app->bind('db.connection', function ($app) {
return $app['db']->connection();
});

$this->app->bind('db.schema', function ($app) {
return $app['db']->connection()->getSchemaBuilder();
});
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Support/Facades/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public static function connection($name)
}

/**
* Get a schema builder instance for the default connection.
* Get the registered name of the component.
*
* @return \Illuminate\Database\Schema\Builder
* @return string
*/
protected static function getFacadeAccessor()
{
return static::$app['db']->connection()->getSchemaBuilder();
return 'db.schema';
}
}
3 changes: 3 additions & 0 deletions tests/Database/DatabaseMigratorIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public function setUp()

$container = new \Illuminate\Container\Container;
$container->instance('db', $db->getDatabaseManager());
$container->bind('db.schema', function ($c) {
return $c['db']->connection()->getSchemaBuilder();
});
\Illuminate\Support\Facades\Facade::setFacadeApplication($container);

$this->migrator = new Migrator(
Expand Down

0 comments on commit 0dd0c63

Please sign in to comment.