Transfer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 31
c 1
b 0
f 0
dl 0
loc 59
rs 10
ccs 12
cts 12
cp 1
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A withdraw() 0 3 1
A from() 0 3 1
A deposit() 0 3 1
A to() 0 3 1
A toWallet() 0 3 1
A fromWallet() 0 3 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