Completed
Push — master ( c53116...d0984d )
by Jeremy
07:52
created

DatabaseTraits   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A getConnectionName() 0 3 1
A getTableName() 0 3 1
1
<?php
2
3
namespace jeremykenedy\LaravelRoles\Traits;
4
5
trait DatabaseTraits
6
{
7
    /**
8
     * The table associated with the model.
9
     *
10
     * @var string
11
     */
12
    protected $table;
13
14
    /**
15
     * The connection name for the model.
16
     *
17
     * @var string
18
     */
19
    protected $connection;
20
21
    /**
22
     * Create a new instance to set the table and connection.
23
     *
24
     * @return void
25
     */
26
    public function __construct($attributes = [])
27
    {
28
        parent::__construct($attributes);
29
        if ($connection = config('roles.connection')) {
30
            $this->connection = $connection;
31
        }
32
    }
33
34
    /**
35
     * Get the database connection.
36
     */
37
    public function getConnectionName()
38
    {
39
        return $this->connection;
40
    }
41
42
    /**
43
     * Get the database table.
44
     */
45
    public function getTableName()
46
    {
47
        return $this->table;
48
    }
49
}
50