Passed
Push — master ( 33ea8c...918c78 )
by Curtis
18:41 queued 12:15
created

ConnectionTrait::getDB()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace App\Traits;
4
5
use Illuminate\Support\Facades\Validator;
6
7
trait ConnectionTrait
8
{
9
    public function setConnection($conn='mysql', $db='enso')
10
    {
11
        \Session::put('conn', $conn);
12
        \Session::put('db', $db);
13
    }
14
15
    public function getConnection()
16
    {
17
        $conn = \Session::get('conn');
18
        $db = \Session::get('db');
19
        if($conn == 'tenant') {
20
            $key = 'database.connections.tenant.database';
21
            $value = $db;
22
            config([$key => $value]);
23
        }
24
        return $conn;
25
    }
26
27
    public function getDB()
28
    {
29
        $db = \Session::get('db');
30
        return $db;
31
    }
32
33
}
34