Test Failed
Pull Request — master (#83)
by Бабичев
04:37
created

Transfer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 22
c 2
b 0
f 0
dl 0
loc 66
ccs 4
cts 12
cp 0.3333
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTable() 0 7 2
A from() 0 3 1
A to() 0 3 1
A withdraw() 0 3 1
A deposit() 0 3 1
1
<?php
2
3
namespace Bavix\Wallet\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
use Illuminate\Database\Eloquent\Relations\MorphTo;
8
use function config;
9
10
/**
11
 * Class Transfer
12
 * @package Bavix\Wallet\Models
13
 *
14
 * @property string $status
15
 * @property int $deposit_id
16
 * @property int $withdraw_id
17
 * @property string $from_type
18
 * @property int $from_id
19
 * @property string $to_type
20
 * @property int $to_id
21
 * @property string $uuid
22
 * @property int $fee
23
 *
24
 * @property Transaction $deposit
25
 * @property Transaction $withdraw
26
 */
27
class Transfer extends Model
28
{
29
30
    public const STATUS_EXCHANGE = 'exchange';
31
    public const STATUS_TRANSFER = 'transfer';
32
    public const STATUS_PAID = 'paid';
33
    public const STATUS_REFUND = 'refund';
34
    public const STATUS_GIFT = 'gift';
35
36
    /**
37
     * @var array
38
     */
39
    protected $fillable = [
40
        'status',
41
        'deposit_id',
42
        'withdraw_id',
43
        'from_type',
44
        'from_id',
45
        'to_type',
46
        'to_id',
47
        'uuid',
48
        'fee',
49
    ];
50
51
    /**
52
     * @return string
53
     */
54 60
    public function getTable(): string
55
    {
56 60
        if (!$this->table) {
57 60
            $this->table = config('wallet.transfer.table');
58
        }
59
60 60
        return parent::getTable();
61
    }
62
63
    /**
64
     * @return MorphTo
65
     */
66
    public function from(): MorphTo
67
    {
68
        return $this->morphTo();
69
    }
70
71
    /**
72
     * @return MorphTo
73
     */
74
    public function to(): MorphTo
75
    {
76
        return $this->morphTo();
77
    }
78
79
    /**
80
     * @return BelongsTo
81
     */
82
    public function deposit(): BelongsTo
83
    {
84
        return $this->belongsTo(Transaction::class, 'deposit_id');
85
    }
86
87
    /**
88
     * @return BelongsTo
89
     */
90
    public function withdraw(): BelongsTo
91
    {
92
        return $this->belongsTo(Transaction::class, 'withdraw_id');
93
    }
94
95
}
96