Passed
Push — master ( 2a11a1...9edf84 )
by Бабичев
56s
created

Transaction::getTable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Bavix\Wallet\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\MorphTo;
7
8
class Transaction extends Model
9
{
10
11
    /**
12
     * @var array
13
     */
14
    protected $fillable = [
15
        'payable_type',
16
        'payable_id',
17
        'uuid',
18
        'type',
19
        'amount',
20
        'confirmed',
21
        'meta',
22
    ];
23
24
    /**
25
     * @var array
26
     */
27
    protected $casts = [
28
        'amount' => 'int',
29
        'confirmed' => 'bool',
30
        'meta' => 'json'
31
    ];
32
33
    /**
34
     * @return string
35
     */
36 13
    public function getTable(): string
37
    {
38 13
        if (!$this->table) {
39 13
            $this->table = \config('wallet.transaction.table');
40
        }
41
42 13
        return parent::getTable();
43
    }
44
45
    /**
46
     * @return MorphTo
47
     */
48 1
    public function payable(): MorphTo
49
    {
50 1
        return $this->morphTo();
51
    }
52
53
}
54