forked from illuminate/database
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseServiceProvider.php
More file actions
Latest commit
45 lines (38 loc) · 1.26 KB
/
Copy pathDatabaseServiceProvider.php
File metadata and controls
45 lines (38 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?phpnamespaceIlluminate\Database;
useIlluminate\Database\Eloquent\Model;
useIlluminate\Support\ServiceProvider;
useIlluminate\Database\Connectors\ConnectionFactory;
class DatabaseServiceProvider extends ServiceProvider {
/**
* Register the service provider.
*
* @return void
*/
publicfunctionregister()
{
// The connection factory is used to create the actual connection instances on
// the database. We will inject the factory into the manager so that it may
// make the connections while they are actually needed and not of before.
$this->app['db.factory'] = $this->app->share(function()
{
returnnewConnectionFactory;
});
// The database manager is used to resolve various connections, since multiple
// connections might be managed. It also implements the connection resolver
// interface which may be used by other components requiring connections.
$this->app['db'] = $this->app->share(function($app)
{
returnnewDatabaseManager($app, $app['db.factory']);
});
$this->registerEloquent();
}
/**
* Register the database connections with the Eloquent ORM.
*
* @return void
*/
protectedfunctionregisterEloquent()
{
Model::setConnectionResolver($this->app['db']);
}
}