Passed
Push — master ( 38cc9b...2ce834 )
by Moecasts
03:22
created

Transfer::to()   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 Moecasts\Laravel\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 Moecasts\Laravel\Wallet\Models\Transaction;
9
10
class Transfer extends Model
11
{
12
    public const ACTION_TRANSFER = 'transfer';
13
    public const ACTION_READ = 'read';
14
    public const ACTION_DOWNLOAD = 'download';
15
    public const ACTION_SUBSCRIBE = 'subscribe';
16
    public const ACTION_TRIAL = 'trial';
17
    public const ACTION_PAID = 'paid';
18
    public const ACTION_REFUND = 'refund';
19
    public const ACTION_GIFT = 'gift';
20
21
    protected $fillable = [
22
        'deposit_id',
23
        'withdraw_id',
24
        'from_type',
25
        'from_id',
26
        'from_wallet_id',
27
        'to_type',
28
        'to_id',
29
        'to_wallet_id',
30
        'action',
31
        'uuid',
32
        'fee',
33
        'refund'
34
    ];
35
36
    protected $casts = [
37
        'refund' => 'boolean'
38
    ];
39
40 1
    public function from(): MorphTo
41
    {
42 1
        return $this->morphTo();
43
    }
44
45 2
    public function fromWallet(): BelongsTo
46
    {
47 2
        return $this->belongsTo(Wallet::class);
48
    }
49
50 1
    public function to(): MorphTo
51
    {
52 1
        return $this->morphTo();
53
    }
54
55 2
    public function toWallet(): BelongsTo
56
    {
57 2
        return $this->belongsTo(Wallet::class);
58
    }
59
60 2
    public function deposit(): BelongsTo
61
    {
62 2
        return $this->belongsTo(Transaction::class, 'deposit_id');
63
    }
64
65 2
    public function withdraw(): BelongsTo
66
    {
67 2
        return $this->belongsTo(Transaction::class, 'withdraw_id');
68
    }
69
}
70