Skip to content

Commit 0dd0c63

Browse files
franzliedketaylorotwell
authored andcommitted
[5.8] Register binding for schema facade (#25512)
* Register binding for schema builder * Use new service binding in Schema facade
1 parent c0c022e commit 0dd0c63

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/Illuminate/Database/DatabaseServiceProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ protected function registerConnectionServices()
6565
$this->app->bind('db.connection', function ($app) {
6666
return $app['db']->connection();
6767
});
68+
69+
$this->app->bind('db.schema', function ($app) {
70+
return $app['db']->connection()->getSchemaBuilder();
71+
});
6872
}
6973

7074
/**

src/Illuminate/Support/Facades/Schema.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public static function connection($name)
2525
}
2626

2727
/**
28-
* Get a schema builder instance for the default connection.
28+
* Get the registered name of the component.
2929
*
30-
* @return \Illuminate\Database\Schema\Builder
30+
* @return string
3131
*/
3232
protected static function getFacadeAccessor()
3333
{
34-
return static::$app['db']->connection()->getSchemaBuilder();
34+
return 'db.schema';
3535
}
3636
}

tests/Database/DatabaseMigratorIntegrationTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public function setUp()
3232

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

3740
$this->migrator = new Migrator(

0 commit comments

Comments
 (0)