|
2 | 2 |
|
3 | 3 | namespace HPWebdeveloper\LaravelPayPocket\Services; |
4 | 4 |
|
5 | | -use Illuminate\Database\Eloquent\Model; |
| 5 | +use HPWebdeveloper\LaravelPayPocket\Exceptions\InsufficientBalanceException; |
| 6 | +use HPWebdeveloper\LaravelPayPocket\Interfaces\WalletOperations; |
6 | 7 |
|
7 | 8 | class PocketServices |
8 | 9 | { |
9 | 10 | /** |
10 | 11 | * Deposit an amount to the user's wallet of a specific type. |
11 | | - * |
12 | | - * @param ?string $notes |
13 | 12 | */ |
14 | | - public function deposit(Model $user, string $type, int|float $amount, ?string $notes = null): bool |
| 13 | + public function deposit(WalletOperations $user, string $type, int|float $amount, ?string $notes = null): bool |
15 | 14 | { |
16 | 15 | return $user->deposit($type, $amount, $notes); |
17 | 16 | } |
18 | 17 |
|
19 | 18 | /** |
20 | 19 | * Pay the order value from the user's wallets. |
21 | 20 | * |
22 | | - * @param ?string $notes |
23 | | - * |
24 | | - * @throws \HPWebdeveloper\LaravelPayPocket\Exceptions\InsufficientBalanceException |
| 21 | + * @throws InsufficientBalanceException |
25 | 22 | */ |
26 | | - public function pay(Model $user, int|float $orderValue, ?string $notes = null): void |
| 23 | + public function pay(WalletOperations $user, int|float $orderValue, ?string $notes = null): void |
27 | 24 | { |
28 | 25 | $user->pay($orderValue, $notes); |
29 | 26 | } |
30 | 27 |
|
31 | 28 | /** |
32 | 29 | * Get the balance of the user. |
33 | 30 | */ |
34 | | - public function checkBalance(Model $user): int|float |
| 31 | + public function checkBalance(WalletOperations $user): int|float |
35 | 32 | { |
36 | | - return $user->walletBalance; |
| 33 | + return $user->getWalletBalance(); |
37 | 34 | } |
38 | 35 |
|
39 | 36 | /** |
40 | 37 | * Get the balance of a specific wallet type. |
41 | 38 | */ |
42 | | - public function walletBalanceByType(Model $user, string $type): float|int |
| 39 | + public function walletBalanceByType(WalletOperations $user, string $type): int|float |
43 | 40 | { |
44 | 41 | return $user->getWalletBalanceByType($type); |
45 | 42 | } |
|
0 commit comments