Completed
Push — master ( f01045...b18803 )
by ARCANEDEV
07:38
created

Model::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php namespace Arcanedev\LaravelTracker\Models;
2
3
use Arcanedev\Support\Bases\Model as BaseModel;
4
5
/**
6
 * Class     Model
7
 *
8
 * @package  Arcanedev\LaravelTracker\Models
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
abstract class Model extends BaseModel
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Constructor
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Create a new Eloquent model instance.
19
     *
20
     * @param  array  $attributes
21
     */
22 6
    public function __construct(array $attributes = [])
23
    {
24 6
        $this->setConnection($this->getConfig('database.connection', null))
25 6
             ->setPrefix($this->getConfig('database.prefix', 'tracker_'));
26
27 6
        parent::__construct($attributes);
28 6
    }
29
30
    /* ------------------------------------------------------------------------------------------------
31
     |  Other Functions
32
     | ------------------------------------------------------------------------------------------------
33
     */
34
    /**
35
     * Get the tracker config.
36
     *
37
     * @param  string      $key
38
     * @param  mixed|null  $default
39
     *
40
     * @return mixed
41
     */
42 6
    protected function getConfig($key, $default = null)
43
    {
44 6
        return config("laravel-tracker.$key", $default);
45
    }
46
}
47