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

Transaction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 43
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTable() 0 7 2
A payable() 0 3 1
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