1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bavix\Wallet\Models; |
4
|
|
|
|
5
|
|
|
use Bavix\Wallet\Interfaces\Customer; |
6
|
|
|
use Bavix\Wallet\Interfaces\WalletFloat; |
7
|
|
|
use Bavix\Wallet\Traits\CanBePaid; |
8
|
|
|
use Bavix\Wallet\Traits\HasWalletFloat; |
9
|
|
|
use Illuminate\Database\Eloquent\Model; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class Wallet |
13
|
|
|
* @package Bavix\Wallet\Models |
14
|
|
|
* @property int $balance |
15
|
|
|
*/ |
16
|
|
|
class Wallet extends Model implements Customer, WalletFloat |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
use HasWalletFloat, CanBePaid { |
20
|
|
|
CanBePaid::checkAmount insteadof HasWalletFloat; |
21
|
|
|
CanBePaid::deposit insteadof HasWalletFloat; |
22
|
|
|
CanBePaid::withdraw insteadof HasWalletFloat; |
23
|
|
|
CanBePaid::canWithdraw insteadof HasWalletFloat; |
24
|
|
|
CanBePaid::forceWithdraw insteadof HasWalletFloat; |
25
|
|
|
CanBePaid::transfer insteadof HasWalletFloat; |
26
|
|
|
CanBePaid::safeTransfer insteadof HasWalletFloat; |
27
|
|
|
CanBePaid::forceTransfer insteadof HasWalletFloat; |
28
|
|
|
CanBePaid::assemble insteadof HasWalletFloat; |
29
|
|
|
CanBePaid::change insteadof HasWalletFloat; |
30
|
|
|
CanBePaid::transactions insteadof HasWalletFloat; |
31
|
|
|
CanBePaid::transfers insteadof HasWalletFloat; |
32
|
|
|
CanBePaid::wallets insteadof HasWalletFloat; |
33
|
|
|
CanBePaid::wallet insteadof HasWalletFloat; |
34
|
|
|
CanBePaid::getBalanceAttribute insteadof HasWalletFloat; |
35
|
|
|
CanBePaid::addBalance insteadof HasWalletFloat; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var array |
40
|
|
|
*/ |
41
|
|
|
protected $fillable = [ |
42
|
|
|
'holder_type', |
43
|
|
|
'holder_id', |
44
|
|
|
'name', |
45
|
|
|
'slug', |
46
|
|
|
'description', |
47
|
|
|
'balance', |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var array |
52
|
|
|
*/ |
53
|
|
|
protected $casts = [ |
54
|
|
|
'balance' => 'int', |
55
|
|
|
]; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
21 |
|
public function getTable(): string |
61
|
|
|
{ |
62
|
21 |
|
if (!$this->table) { |
63
|
21 |
|
$this->table = \config('wallet.wallet.table'); |
64
|
|
|
} |
65
|
|
|
|
66
|
21 |
|
return parent::getTable(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|