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

DatabaseTraits::getTableName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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