Test Failed
Push — master ( 72daf6...986bed )
by Бабичев
03:30
created

Transfer::from()   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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
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\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_TRANSFER = 'transfer';
31
    public const STATUS_PAID = 'paid';
32
    public const STATUS_REFUND = 'refund';
33
    public const STATUS_GIFT = 'gift';
34
35
    /**
36
     * @var array
37
     */
38
    protected $fillable = [
39
        'status',
40
        'deposit_id',
41
        'withdraw_id',
42
        'from_type',
43
        'from_id',
44
        'to_type',
45
        'to_id',
46
        'uuid',
47
        'fee',
48
    ];
49
50
    /**
51
     * @return string
52
     */
53
    public function getTable(): string
54
    {
55
        if (!$this->table) {
56
            $this->table = config('wallet.transfer.table');
57
        }
58
59
        return parent::getTable();
60
    }
61
62
    /**
63
     * @return MorphTo
64
     */
65
    public function from(): MorphTo
66
    {
67
        return $this->morphTo();
68
    }
69
70
    /**
71
     * @return MorphTo
72
     */
73
    public function to(): MorphTo
74
    {
75
        return $this->morphTo();
76
    }
77
78
    /**
79
     * @return BelongsTo
80
     */
81
    public function deposit(): BelongsTo
82
    {
83
        return $this->belongsTo(Transaction::class, 'deposit_id');
84
    }
85
86
    /**
87
     * @return BelongsTo
88
     */
89
    public function withdraw(): BelongsTo
90
    {
91
        return $this->belongsTo(Transaction::class, 'withdraw_id');
92
    }
93
94
}
95