Transfer::deposit()   A
last analyzed

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 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
rs 10
ccs 2
cts 2
cp 1
crap 1
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
    public const ACTION_EXCHANGE = 'exchange';
21
22
    protected $fillable = [
23
        'deposit_id',
24
        'withdraw_id',
25
        'from_type',
26
        'from_id',
27
        'from_wallet_id',
28
        'to_type',
29
        'to_id',
30
        'to_wallet_id',
31
        'action',
32
        'uuid',
33
        'fee',
34
        'refund'
35
    ];
36
37
    protected $casts = [
38
        'refund' => 'boolean'
39
    ];
40
41 1
    public function from(): MorphTo
42
    {
43 1
        return $this->morphTo();
44
    }
45
46 4
    public function fromWallet(): BelongsTo
47
    {
48 4
        return $this->belongsTo(Wallet::class);
49
    }
50
51 1
    public function to(): MorphTo
52
    {
53 1
        return $this->morphTo();
54
    }
55
56 4
    public function toWallet(): BelongsTo
57
    {
58 4
        return $this->belongsTo(Wallet::class);
59
    }
60
61 2
    public function deposit(): BelongsTo
62
    {
63 2
        return $this->belongsTo(Transaction::class, 'deposit_id');
64
    }
65
66 2
    public function withdraw(): BelongsTo
67
    {
68 2
        return $this->belongsTo(Transaction::class, 'withdraw_id');
69
    }
70
}
71