Passed
Pull Request — master (#13)
by Бабичев
01:59
created

Transfer::deposit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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
9
class Transfer extends Model
10
{
11
12
    /**
13
     * @var array
14
     */
15
    protected $fillable = [
16
        'deposit_id',
17
        'withdraw_id',
18
        'from_type',
19
        'from_id',
20
        'to_type',
21
        'to_id',
22
        'refund',
23
        'uuid',
24
    ];
25
26
    /**
27
     * @return string
28
     */
29 13
    public function getTable(): string
30
    {
31 13
        if (!$this->table) {
32 13
            $this->table = \config('wallet.transfer.table');
33
        }
34
35 13
        return parent::getTable();
36
    }
37
38
    /**
39
     * @return MorphTo
40
     */
41 1
    public function from(): MorphTo
42
    {
43 1
        return $this->morphTo();
44
    }
45
46
    /**
47
     * @return MorphTo
48
     */
49 1
    public function to(): MorphTo
50
    {
51 1
        return $this->morphTo();
52
    }
53
54
    /**
55
     * @return BelongsTo
56
     */
57 1
    public function deposit(): BelongsTo
58
    {
59 1
        return $this->belongsTo(Transaction::class, 'deposit_id');
60
    }
61
62
    /**
63
     * @return BelongsTo
64
     */
65 1
    public function withdraw(): BelongsTo
66
    {
67 1
        return $this->belongsTo(Transaction::class, 'withdraw_id');
68
    }
69
70
}
71