@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | trait CanPay { |
| 12 | 12 | public function pay(Product $product, string $action = Transfer::ACTION_PAID, bool $force = false): Transfer |
| 13 | 13 | { |
| 14 | - if (! $product->canBePaid($this, $force)) { |
|
| 14 | + if (!$product->canBePaid($this, $force)) { |
|
| 15 | 15 | throw new ProductEnded(trans('wallet::errors.product_stock')); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -60,12 +60,12 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $transfer = $this->paid($product, $action); |
| 62 | 62 | |
| 63 | - if (! $transfer) { |
|
| 63 | + if (!$transfer) { |
|
| 64 | 64 | throw (new ModelNotFoundException()) |
| 65 | 65 | ->setModel(config('wallet.transfer.model')); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - return \DB::transaction(function () use ($transfer) { |
|
| 68 | + return \DB::transaction(function() use ($transfer) { |
|
| 69 | 69 | $transfer->withdraw->update([ |
| 70 | 70 | 'confirmed' => false, |
| 71 | 71 | ]); |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function getWallet(string $currency): ?Wallet |
| 21 | 21 | { |
| 22 | - if (! in_array($currency, config('wallet.currencies'))) { |
|
| 22 | + if (!in_array($currency, config('wallet.currencies'))) { |
|
| 23 | 23 | throw new CurrencyInvalid(trans('wallet::errors.currency_unsupported')); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $wallet = $this->wallets()->where('currency', $currency)->first(); |
| 27 | 27 | |
| 28 | - if (! $wallet) { |
|
| 28 | + if (!$wallet) { |
|
| 29 | 29 | $wallet = $this->wallets()->create([ |
| 30 | 30 | 'currency' => $currency, |
| 31 | 31 | 'balance' => 0 |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $transfer = $this->paid($product, $action); |
| 66 | 66 | |
| 67 | - if (! $transfer) { |
|
| 67 | + if (!$transfer) { |
|
| 68 | 68 | throw (new ModelNotFoundException()) |
| 69 | 69 | ->setModel(config('wallet.transfer.model')); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return \DB::transaction(function () use ($transfer) { |
|
| 72 | + return \DB::transaction(function() use ($transfer) { |
|
| 73 | 73 | $transfer->withdraw->update([ |
| 74 | 74 | 'confirmed' => false, |
| 75 | 75 | ]); |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * @param float $amount |
| 17 | 17 | * @return float |
| 18 | 18 | */ |
| 19 | - public static function fee(Assemblable $assemblable, Wallet $wallet,float $amount): float |
|
| 19 | + public static function fee(Assemblable $assemblable, Wallet $wallet, float $amount): float |
|
| 20 | 20 | { |
| 21 | 21 | if ($assemblable instanceof Taxing) { |
| 22 | 22 | return (float) ($amount * $wallet->coefficient($wallet->currency) * $assemblable->getFeePercent() / 100); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | protected function change(string $type, int $amount, ?array $meta, bool $confirmed): Transaction |
| 70 | 70 | { |
| 71 | - return DB::transaction(function () use ($type, $amount, $meta, $confirmed) { |
|
| 71 | + return DB::transaction(function() use ($type, $amount, $meta, $confirmed) { |
|
| 72 | 72 | if ($confirmed) { |
| 73 | 73 | $this->addBalance($amount); |
| 74 | 74 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | $this->exists or $this->save(); |
| 106 | 106 | |
| 107 | - if (! WalletProxy::has($this->getKey())) { |
|
| 107 | + if (!WalletProxy::has($this->getKey())) { |
|
| 108 | 108 | $balance = $this->attributes['balance'] / $this->coefficient($this->attributes['currency']); |
| 109 | 109 | WalletProxy::set($this->getKey(), (float) ($balance ?? 0)); |
| 110 | 110 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | { |
| 126 | 126 | $wallet = $transferable->getReceiptWallet($this->currency); |
| 127 | 127 | |
| 128 | - return DB::transaction(function () use ($transferable, $amount, $wallet, $meta, $action) { |
|
| 128 | + return DB::transaction(function() use ($transferable, $amount, $wallet, $meta, $action) { |
|
| 129 | 129 | $fee = Tax::fee($transferable, $wallet, $amount); |
| 130 | 130 | $withdraw = $this->withdraw($amount + $fee, $meta); |
| 131 | 131 | $deposit = $wallet->deposit($amount, $meta); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | public function withdraw(float $amount, ?array $meta = null, bool $confirmed = true): Transaction |
| 137 | 137 | { |
| 138 | - if (! $this->canWithdraw($amount)) { |
|
| 138 | + if (!$this->canWithdraw($amount)) { |
|
| 139 | 139 | throw new InsufficientFunds(trans('wallet::errors.insufficient_funds')); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | { |
| 178 | 178 | $wallet = $transferable->getReceiptWallet($this->currency); |
| 179 | 179 | |
| 180 | - return DB::transaction(function () use ($transferable, $amount, $wallet, $meta, $action) { |
|
| 180 | + return DB::transaction(function() use ($transferable, $amount, $wallet, $meta, $action) { |
|
| 181 | 181 | $fee = Tax::fee($transferable, $wallet, $amount); |
| 182 | 182 | $withdraw = $this->forceWithdraw($amount + $fee, $meta); |
| 183 | 183 | $deposit = $wallet->deposit($amount, $meta); |
@@ -191,14 +191,14 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | $exchangeRate = config('wallet.exchange.' . $this->currency . '.' . $currency); |
| 193 | 193 | |
| 194 | - if (! $exchangeRate || |
|
| 195 | - ! $this->holder instanceof Exchangeable) { |
|
| 194 | + if (!$exchangeRate || |
|
| 195 | + !$this->holder instanceof Exchangeable) { |
|
| 196 | 196 | throw new ExchangeInvalid(trans('wallet::errors.exchange_unsupported')); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | $exchangedAmount = $amount * $exchangeRate; |
| 200 | 200 | |
| 201 | - return DB::transaction(function () use ($wallet, $amount, $exchangedAmount, $meta, $action) { |
|
| 201 | + return DB::transaction(function() use ($wallet, $amount, $exchangedAmount, $meta, $action) { |
|
| 202 | 202 | $fee = Tax::fee($this->holder, $wallet, $amount); |
| 203 | 203 | $withdraw = $this->withdraw($amount + $fee, $meta); |
| 204 | 204 | $deposit = $wallet->deposit($exchangedAmount, $meta); |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | $exchangeRate = config('wallet.exchange.' . $this->currency . '.' . $currency); |
| 223 | 223 | |
| 224 | - if (! $exchangeRate || |
|
| 225 | - ! $this->holder instanceof Exchangeable) { |
|
| 224 | + if (!$exchangeRate || |
|
| 225 | + !$this->holder instanceof Exchangeable) { |
|
| 226 | 226 | throw new ExchangeInvalid(trans('wallet::errors.exchange_unsupported')); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | $exchangedAmount = $amount * $exchangeRate; |
| 230 | 230 | |
| 231 | - return DB::transaction(function () use ($wallet, $amount, $exchangedAmount, $meta, $action) { |
|
| 231 | + return DB::transaction(function() use ($wallet, $amount, $exchangedAmount, $meta, $action) { |
|
| 232 | 232 | $fee = Tax::fee($this->holder, $wallet, $amount); |
| 233 | 233 | $withdraw = $this->forceWithdraw($amount + $fee, $meta); |
| 234 | 234 | $deposit = $wallet->deposit($exchangedAmount, $meta); |
@@ -257,6 +257,6 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | public function coefficient(string $currency = ''): float |
| 259 | 259 | { |
| 260 | - return config('wallet.coefficient.' . $currency , 100.); |
|
| 260 | + return config('wallet.coefficient.' . $currency, 100.); |
|
| 261 | 261 | } |
| 262 | 262 | } |