Completed
Push — master ( 4f3de5...9b9e7a )
by Pavel
05:51
created

DatabaseServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 13 2
1
<?php
2
3
namespace App\Providers;
4
5
use Illuminate\Database\Capsule\Manager as Capsule;
6
use Illuminate\Events\Dispatcher;
7
use Illuminate\Container\Container as IlluminateContainer;
8
use Pimple\Container;
9
10
final class DatabaseServiceProvider extends BaseServiceProvider
11
{
12
    /**
13
     * Register database service provider.
14
     *
15
     * @param Container $container
16
     */
17
    public function register(Container $container)
18
    {
19
        $config  = $container['settings'];
20
        $capsule = new Capsule;
21
        foreach ($config['database']['connections'] as $name => $connection) {
22
            $capsule->addConnection($connection, $name);
23
        }
24
        $capsule->setEventDispatcher(new Dispatcher(new IlluminateContainer));
25
        $capsule->setAsGlobal();
26
        $capsule->bootEloquent();
27
28
        $container['databaseManager'] = $capsule->getDatabaseManager();
29
    }
30
}
31