Test Failed
Pull Request — master (#83)
by Бабичев
13:48 queued 09:03
created

Transfer::withdraw()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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