Skip to content

Commit 96036ab

Browse files
committed
Move register code to boot
1 parent 266be12 commit 96036ab

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/Jenssegers/Mongodb/MongodbServiceProvider.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ class MongodbServiceProvider extends ServiceProvider {
1313
*/
1414
public function boot()
1515
{
16+
// Add a mongodb extension to the original database manager.
17+
$this->app['db']->extend('mongodb', function($config)
18+
{
19+
return new Connection($config);
20+
});
21+
1622
Model::setConnectionResolver($this->app['db']);
1723

1824
Model::setEventDispatcher($this->app['events']);
@@ -25,15 +31,7 @@ public function boot()
2531
*/
2632
public function register()
2733
{
28-
// Add a mongodb extension to the original database manager,
29-
// when the database instance is being resolved.
30-
$this->app->resolving('db', function($db)
31-
{
32-
$db->extend('mongodb', function($config)
33-
{
34-
return new Connection($config);
35-
});
36-
});
34+
// Nothing.
3735
}
3836

3937
}

0 commit comments

Comments
 (0)